output.var = params$output.var
transform.abs = FALSE
log.pred = params$log.pred
norm.pred = FALSE
algo.forward.caret = params$algo.forward.caret
algo.backward.caret = params$algo.backward.caret
algo.stepwise.caret = params$algo.stepwise.caret
algo.LASSO.caret = params$algo.LASSO.caret
algo.LARS.caret = params$algo.LARS.caret
message("Parameters used for training/prediction: ")
## Parameters used for training/prediction:
str(params)
## List of 7
## $ output.var : chr "y3"
## $ log.pred : logi TRUE
## $ algo.forward.caret : logi TRUE
## $ algo.backward.caret: logi TRUE
## $ algo.stepwise.caret: logi TRUE
## $ algo.LASSO.caret : logi TRUE
## $ algo.LARS.caret : logi TRUE
# Setup Labels
output.var.tr = if (log.pred == TRUE) paste0(output.var,'.log') else output.var.tr = output.var
feat = read.csv('../../Data/features_highprec.csv')
labels = read.csv('../../Data/labels.csv')
predictors = names(dplyr::select(feat,-JobName))
data.ori = inner_join(feat,labels,by='JobName')
#data.ori = inner_join(feat,select_at(labels,c('JobName',output.var)),by='JobName')
cc = complete.cases(data.ori)
data.notComplete = data.ori[! cc,]
data = data.ori[cc,] %>% select_at(c(predictors,output.var,'JobName'))
message('Original cases: ',nrow(data.ori))
## Original cases: 10000
message('Non-Complete cases: ',nrow(data.notComplete))
## Non-Complete cases: 3020
message('Complete cases: ',nrow(data))
## Complete cases: 6980
summary(dplyr::select_at(data,c('JobName',output.var)))
## JobName y3
## Job_00001: 1 Min. : 95.91
## Job_00002: 1 1st Qu.:118.29
## Job_00003: 1 Median :124.03
## Job_00004: 1 Mean :125.40
## Job_00007: 1 3rd Qu.:131.06
## Job_00008: 1 Max. :193.73
## (Other) :6974
The Output Variable y3 shows right skewness, so will proceed with a log transformation
df=gather(select_at(data,output.var))
ggplot(df, aes(x=value)) +
geom_histogram(aes(y=..density..),bins = 50,fill='light blue') +
geom_density()
#stat_function(fun = dnorm, n = 100, args = list(mean = mean(df$value), sd = sd(df$value)))
ggplot(gather(select_at(data,output.var)), aes(sample=value)) +
stat_qq() +
facet_wrap(~key, scales = 'free',ncol=4)
if(log.pred==TRUE) data[[output.var.tr]] = log(data[[output.var]],10) else
data[[output.var.tr]] = data[[output.var]]
df=gather(select_at(data,c(output.var,output.var.tr)))
ggplot(df, aes(value)) +
geom_histogram(aes(y=..density..),bins = 50,fill='light blue') +
geom_density() +
# stat_function(fun = dnorm, n = 100, args = list(mean = mean(df$value), sd = sd(df$value)))
facet_wrap(~key, scales = 'free',ncol=2)
ggplot(gather(select_at(data,c(output.var,output.var.tr))), aes(sample=value)) +
stat_qq() +
facet_wrap(~key, scales = 'free',ncol=4)
Normalization of y3 using bestNormalize package. (suggested orderNorm) This is cool, but I think is too far for the objective of the project
t=bestNormalize::bestNormalize(data[[output.var]])
t
## Best Normalizing transformation with 6980 Observations
## Estimated Normality Statistics (Pearson P / df, lower => more normal):
## - No transform: 2.9701
## - Box-Cox: 1.4689
## - Log_b(x+a): 2.0304
## - sqrt(x+a): 2.4534
## - exp(x): 749.244
## - arcsinh(x): 2.0308
## - Yeo-Johnson: 1.1886
## - orderNorm: 1.1943
## Estimation method: Out-of-sample via CV with 10 folds and 5 repeats
##
## Based off these, bestNormalize chose:
## Standardized Yeo-Johnson Transformation with 6980 nonmissing obs.:
## Estimated statistics:
## - lambda = -1.998639
## - mean (before standardization) = 0.5003083
## - sd (before standardization) = 5.108542e-06
qqnorm(data[[output.var]])
qqnorm(predict(t))
orderNorm() is a rank-based procedure by which the values of a vector are mapped to their percentile, which is then mapped to the same percentile of the normal distribution. Without the presence of ties, this essentially guarantees that the transformation leads to a uniform distribution
All predictors show a Fat-Tail situation, where the two tails are very tall, and a low distribution around the mean. The orderNorm transformation can help (see [Best Normalizator] section)
Histograms
cols = c('x11','x18','stat98','x7','stat110')
df=gather(select_at(data,cols))
ggplot(df, aes(value)) +
geom_histogram(aes(y=..density..),bins = 50,fill='light blue') +
geom_density() +
# stat_function(fun = dnorm, n = 100, args = list(mean = mean(df$value), sd = sd(df$value)))
facet_wrap(~key, scales = 'free',ncol=3)
# ggplot(gather(select_at(data,cols)), aes(sample=value)) +
# stat_qq()+
# facet_wrap(~key, scales = 'free',ncol=2)
lapply(select_at(data,cols),summary)
## $x11
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 9.000e-08 9.494e-08 1.001e-07 1.001e-07 1.052e-07 1.100e-07
##
## $x18
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.500 3.147 4.769 4.772 6.418 7.999
##
## $stat98
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -2.998619 -1.551882 -0.015993 -0.005946 1.528405 2.999499
##
## $x7
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.700 1.266 1.854 1.852 2.446 3.000
##
## $stat110
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -2.999543 -1.496865 -0.002193 -0.004129 1.504273 2.999563
Scatter plot vs. output variable **y3.log
d = gather(dplyr::select_at(data,c(cols,output.var.tr)),key=target,value=value,-!!output.var.tr)
ggplot(data=d, aes_string(x='value',y=output.var.tr)) +
geom_point(color='light green',alpha=0.5) +
geom_smooth() +
facet_wrap(~target, scales = 'free',ncol=3)
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
All indicators have a strong indication of Fat-Tails
df=gather(select_at(data,predictors))
ggplot(df, aes(value)) +
geom_histogram(aes(y=..density..),bins = 50,fill='light blue') +
geom_density() +
# stat_function(fun = dnorm, n = 100, args = list(mean = mean(df$value), sd = sd(df$value)))
facet_wrap(~key, scales = 'free',ncol=4)
#chart.Correlation(select(data,-JobName), pch=21)
t=as.data.frame(round(cor(dplyr::select(data,-one_of(output.var.tr,'JobName'))
,select_at(data,output.var.tr)),4)) %>%
rownames_to_column(var='variable') %>% filter(variable != !!output.var) %>% arrange(-y3.log)
#DT::datatable(t)
message("Top Positive")
## Top Positive
kable(head(arrange(t,desc(y3.log)),20))
| variable | y3.log |
|---|---|
| x18 | 0.3120 |
| x7 | 0.2091 |
| stat98 | 0.1784 |
| x9 | 0.1127 |
| x17 | 0.0611 |
| x16 | 0.0489 |
| x10 | 0.0472 |
| x21 | 0.0412 |
| x11 | 0.0322 |
| x8 | 0.0318 |
| stat156 | 0.0287 |
| stat23 | 0.0234 |
| stat100 | 0.0206 |
| stat144 | 0.0203 |
| stat59 | 0.0202 |
| stat60 | 0.0199 |
| stat195 | 0.0199 |
| stat141 | 0.0194 |
| stat73 | 0.0192 |
| stat197 | 0.0185 |
message("Top Negative")
## Top Negative
kable(head(arrange(t,y3.log),20))
| variable | y3.log |
|---|---|
| stat110 | -0.1594 |
| x4 | -0.0603 |
| stat13 | -0.0345 |
| stat41 | -0.0345 |
| stat14 | -0.0317 |
| stat149 | -0.0309 |
| stat113 | -0.0279 |
| stat4 | -0.0248 |
| stat106 | -0.0236 |
| stat146 | -0.0236 |
| stat186 | -0.0217 |
| stat91 | -0.0210 |
| stat214 | -0.0209 |
| stat5 | -0.0207 |
| stat22 | -0.0202 |
| stat39 | -0.0202 |
| stat175 | -0.0194 |
| stat187 | -0.0193 |
| stat128 | -0.0192 |
| stat37 | -0.0191 |
#chart.Correlation(select(data,-JobName), pch=21)
t=as.data.frame(round(cor(dplyr::select(data,-one_of('JobName'))),4))
#DT::datatable(t,options=list(scrollX=T))
message("Showing only 10 variables")
## Showing only 10 variables
kable(t[1:10,1:10])
| x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | |
|---|---|---|---|---|---|---|---|---|---|---|
| x1 | 1.0000 | 0.0034 | -0.0028 | 0.0085 | 0.0068 | 0.0159 | 0.0264 | -0.0012 | 0.0142 | 0.0013 |
| x2 | 0.0034 | 1.0000 | -0.0057 | 0.0004 | -0.0094 | -0.0101 | 0.0089 | 0.0078 | 0.0049 | -0.0214 |
| x3 | -0.0028 | -0.0057 | 1.0000 | 0.0029 | 0.0046 | 0.0006 | -0.0105 | -0.0002 | 0.0167 | -0.0137 |
| x4 | 0.0085 | 0.0004 | 0.0029 | 1.0000 | -0.0059 | 0.0104 | 0.0098 | 0.0053 | 0.0061 | -0.0023 |
| x5 | 0.0068 | -0.0094 | 0.0046 | -0.0059 | 1.0000 | 0.0016 | -0.0027 | 0.0081 | 0.0259 | -0.0081 |
| x6 | 0.0159 | -0.0101 | 0.0006 | 0.0104 | 0.0016 | 1.0000 | 0.0200 | -0.0157 | 0.0117 | -0.0072 |
| x7 | 0.0264 | 0.0089 | -0.0105 | 0.0098 | -0.0027 | 0.0200 | 1.0000 | -0.0018 | -0.0069 | -0.0221 |
| x8 | -0.0012 | 0.0078 | -0.0002 | 0.0053 | 0.0081 | -0.0157 | -0.0018 | 1.0000 | 0.0142 | -0.0004 |
| x9 | 0.0142 | 0.0049 | 0.0167 | 0.0061 | 0.0259 | 0.0117 | -0.0069 | 0.0142 | 1.0000 | 0.0149 |
| x10 | 0.0013 | -0.0214 | -0.0137 | -0.0023 | -0.0081 | -0.0072 | -0.0221 | -0.0004 | 0.0149 | 1.0000 |
Scatter plots with all predictors and the output variable (y3.log)
d = gather(dplyr::select_at(data,c(predictors,output.var.tr)),key=target,value=value,-!!output.var.tr)
ggplot(data=d, aes_string(x='value',y=output.var.tr)) +
geom_point(color='light blue',alpha=0.5) +
geom_smooth() +
facet_wrap(~target, scales = 'free',ncol=4)
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
No Multicollinearity among predictors
Showing Top predictor by VIF Value
vifDF = usdm::vif(select_at(data,predictors)) %>% arrange(desc(VIF))
head(vifDF,15)
## Variables VIF
## 1 stat207 1.062951
## 2 stat137 1.060574
## 3 stat31 1.060402
## 4 stat166 1.060395
## 5 stat6 1.059831
## 6 stat142 1.059533
## 7 stat121 1.059330
## 8 stat206 1.059192
## 9 stat202 1.059150
## 10 stat178 1.059092
## 11 stat20 1.058477
## 12 stat175 1.058138
## 13 stat112 1.057701
## 14 stat146 1.057548
## 15 stat156 1.057245
data.tr=data %>%
mutate(x18.sqrt = sqrt(x18))
cols=c('x18','x18.sqrt')
# ggplot(gather(select_at(data.tr,cols)), aes(value)) +
# geom_histogram(aes(y=..density..),bins = 50,fill='light blue') +
# geom_density() +
# facet_wrap(~key, scales = 'free',ncol=4)
d = gather(dplyr::select_at(data.tr,c(cols,output.var.tr)),key=target,value=value,-!!output.var.tr)
ggplot(data=d, aes_string(x='value',y=output.var.tr)) +
geom_point(color='light blue',alpha=0.5) +
geom_smooth() +
facet_wrap(~target, scales = 'free',ncol=4)
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
#removing unwanted variables
data.tr=data.tr %>%
dplyr::select_at(names(data.tr)[! names(data.tr) %in% c('x18','y3','JobName')])
data=data.tr
label.names=output.var.tr
data = data[sample(nrow(data)),] # randomly shuffle data
pca.vars = names(data)
pca.vars = pca.vars[!pca.vars %in% label.names]
#pca.model = preProcess(data[,pca.vars], method = "pca")
#data.pca = predict(pca.model,data)
#eigenVectors = pca.model$rotation
targetCumVar = .8
pca.model = prcomp(data[,pca.vars],center=T,scale.=T,retx = T)
pca.model$var = pca.model$sdev ^ 2 #eigenvalues
pca.model$pvar = pca.model$var / sum(pca.model$var)
pca.model$cumpvar = cumsum(pca.model$pvar )
pca.model$pcaSel = pca.model$cumpvar<=targetCumVar
pca.model$pcaSelCount = sum(pca.model$pcaSel)
pca.model$pcaSelTotVar = sum(pca.model$pvar[pca.model$pcaSel])
message(pca.model$pcaSelCount, " PCAs justify ",percent(targetCumVar)," of the total Variance. (",percent(pca.model$pcaSelTotVar),")")
## 177 PCAs justify 80.0% of the total Variance. (79.7%)
plot(pca.model$var,xlab="Principal component", ylab="Proportion of variance explained", type='b')
plot(cumsum(pca.model$pvar ),xlab="Principal component", ylab="Cumulative Proportion of variance explained", ylim=c(0,1), type='b')
screeplot(pca.model,npcs = pca.model$pcaSelCount)
screeplot(pca.model,npcs = pca.model$pcaSelCount,type='lines')
summary(pca.model)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10 PC11 PC12
## Standard deviation 1.17904 1.17584 1.17362 1.17015 1.16717 1.16347 1.15866 1.15734 1.15524 1.15379 1.15158 1.15032
## Proportion of Variance 0.00579 0.00576 0.00574 0.00571 0.00568 0.00564 0.00559 0.00558 0.00556 0.00555 0.00553 0.00551
## Cumulative Proportion 0.00579 0.01155 0.01729 0.02300 0.02867 0.03431 0.03991 0.04549 0.05105 0.05660 0.06212 0.06764
## PC13 PC14 PC15 PC16 PC17 PC18 PC19 PC20 PC21 PC22 PC23 PC24
## Standard deviation 1.14783 1.14539 1.14484 1.14203 1.14161 1.14078 1.13593 1.13406 1.13153 1.12860 1.1273 1.12574
## Proportion of Variance 0.00549 0.00547 0.00546 0.00543 0.00543 0.00542 0.00538 0.00536 0.00533 0.00531 0.0053 0.00528
## Cumulative Proportion 0.07312 0.07859 0.08405 0.08949 0.09492 0.10034 0.10572 0.11107 0.11641 0.12172 0.1270 0.13229
## PC25 PC26 PC27 PC28 PC29 PC30 PC31 PC32 PC33 PC34 PC35 PC36
## Standard deviation 1.12538 1.12293 1.12249 1.11902 1.11784 1.1171 1.11463 1.11240 1.11114 1.10898 1.10838 1.10540
## Proportion of Variance 0.00528 0.00525 0.00525 0.00522 0.00521 0.0052 0.00518 0.00516 0.00514 0.00512 0.00512 0.00509
## Cumulative Proportion 0.13757 0.14282 0.14807 0.15329 0.15850 0.1637 0.16887 0.17403 0.17917 0.18430 0.18942 0.19451
## PC37 PC38 PC39 PC40 PC41 PC42 PC43 PC44 PC45 PC46 PC47 PC48
## Standard deviation 1.10363 1.10119 1.09868 1.09712 1.09664 1.0953 1.09342 1.09248 1.09191 1.08993 1.08755 1.08740
## Proportion of Variance 0.00508 0.00505 0.00503 0.00502 0.00501 0.0050 0.00498 0.00497 0.00497 0.00495 0.00493 0.00493
## Cumulative Proportion 0.19958 0.20464 0.20967 0.21468 0.21969 0.2247 0.22967 0.23465 0.23961 0.24456 0.24949 0.25442
## PC49 PC50 PC51 PC52 PC53 PC54 PC55 PC56 PC57 PC58 PC59 PC60
## Standard deviation 1.0848 1.0839 1.08256 1.07975 1.07796 1.07724 1.07681 1.07518 1.0738 1.0732 1.07179 1.06978
## Proportion of Variance 0.0049 0.0049 0.00488 0.00486 0.00484 0.00484 0.00483 0.00482 0.0048 0.0048 0.00479 0.00477
## Cumulative Proportion 0.2593 0.2642 0.26910 0.27396 0.27880 0.28363 0.28847 0.29328 0.2981 0.3029 0.30767 0.31244
## PC61 PC62 PC63 PC64 PC65 PC66 PC67 PC68 PC69 PC70 PC71 PC72
## Standard deviation 1.06760 1.06694 1.06668 1.06530 1.06432 1.06296 1.06035 1.05938 1.05854 1.05756 1.05511 1.05364
## Proportion of Variance 0.00475 0.00474 0.00474 0.00473 0.00472 0.00471 0.00468 0.00468 0.00467 0.00466 0.00464 0.00463
## Cumulative Proportion 0.31719 0.32193 0.32667 0.33140 0.33612 0.34083 0.34551 0.35019 0.35486 0.35952 0.36416 0.36878
## PC73 PC74 PC75 PC76 PC77 PC78 PC79 PC80 PC81 PC82 PC83 PC84
## Standard deviation 1.05283 1.05150 1.0504 1.04991 1.04971 1.04759 1.04638 1.04417 1.04337 1.04268 1.04064 1.04021
## Proportion of Variance 0.00462 0.00461 0.0046 0.00459 0.00459 0.00457 0.00456 0.00454 0.00454 0.00453 0.00451 0.00451
## Cumulative Proportion 0.37340 0.37801 0.3826 0.38720 0.39179 0.39636 0.40092 0.40547 0.41000 0.41453 0.41905 0.42355
## PC85 PC86 PC87 PC88 PC89 PC90 PC91 PC92 PC93 PC94 PC95 PC96
## Standard deviation 1.0387 1.03784 1.03567 1.03512 1.03323 1.03261 1.03067 1.03016 1.02847 1.02686 1.02606 1.02388
## Proportion of Variance 0.0045 0.00449 0.00447 0.00446 0.00445 0.00444 0.00443 0.00442 0.00441 0.00439 0.00439 0.00437
## Cumulative Proportion 0.4280 0.43254 0.43701 0.44147 0.44592 0.45036 0.45479 0.45921 0.46362 0.46801 0.47240 0.47677
## PC97 PC98 PC99 PC100 PC101 PC102 PC103 PC104 PC105 PC106 PC107 PC108
## Standard deviation 1.02321 1.02236 1.02153 1.02046 1.01984 1.01900 1.01740 1.01448 1.01392 1.01179 1.01081 1.00838
## Proportion of Variance 0.00436 0.00436 0.00435 0.00434 0.00433 0.00433 0.00431 0.00429 0.00428 0.00427 0.00426 0.00424
## Cumulative Proportion 0.48113 0.48548 0.48983 0.49417 0.49850 0.50283 0.50714 0.51143 0.51572 0.51998 0.52424 0.52847
## PC109 PC110 PC111 PC112 PC113 PC114 PC115 PC116 PC117 PC118 PC119 PC120
## Standard deviation 1.00788 1.00643 1.00572 1.00466 1.00314 1.00249 1.00058 0.99679 0.99672 0.99594 0.99554 0.99487
## Proportion of Variance 0.00423 0.00422 0.00421 0.00421 0.00419 0.00419 0.00417 0.00414 0.00414 0.00413 0.00413 0.00412
## Cumulative Proportion 0.53271 0.53693 0.54114 0.54535 0.54954 0.55373 0.55790 0.56204 0.56618 0.57031 0.57444 0.57857
## PC121 PC122 PC123 PC124 PC125 PC126 PC127 PC128 PC129 PC130 PC131 PC132
## Standard deviation 0.99314 0.99094 0.99017 0.98931 0.98824 0.98724 0.98619 0.98451 0.98265 0.98147 0.98058 0.9795
## Proportion of Variance 0.00411 0.00409 0.00409 0.00408 0.00407 0.00406 0.00405 0.00404 0.00402 0.00401 0.00401 0.0040
## Cumulative Proportion 0.58268 0.58677 0.59085 0.59493 0.59900 0.60306 0.60711 0.61115 0.61517 0.61919 0.62319 0.6272
## PC133 PC134 PC135 PC136 PC137 PC138 PC139 PC140 PC141 PC142 PC143 PC144
## Standard deviation 0.97894 0.97768 0.97560 0.97556 0.97296 0.97076 0.96990 0.96870 0.96836 0.96667 0.96534 0.96506
## Proportion of Variance 0.00399 0.00398 0.00397 0.00397 0.00394 0.00393 0.00392 0.00391 0.00391 0.00389 0.00388 0.00388
## Cumulative Proportion 0.63118 0.63517 0.63913 0.64310 0.64704 0.65097 0.65489 0.65880 0.66271 0.66660 0.67048 0.67436
## PC145 PC146 PC147 PC148 PC149 PC150 PC151 PC152 PC153 PC154 PC155 PC156
## Standard deviation 0.96324 0.96255 0.96210 0.96047 0.95901 0.95753 0.95677 0.95569 0.95395 0.95280 0.95148 0.94924
## Proportion of Variance 0.00387 0.00386 0.00386 0.00384 0.00383 0.00382 0.00381 0.00381 0.00379 0.00378 0.00377 0.00375
## Cumulative Proportion 0.67823 0.68209 0.68595 0.68979 0.69362 0.69744 0.70126 0.70506 0.70885 0.71264 0.71641 0.72016
## PC157 PC158 PC159 PC160 PC161 PC162 PC163 PC164 PC165 PC166 PC167 PC168
## Standard deviation 0.94857 0.94819 0.94749 0.94599 0.94465 0.94380 0.94369 0.9418 0.94114 0.93935 0.93790 0.93584
## Proportion of Variance 0.00375 0.00375 0.00374 0.00373 0.00372 0.00371 0.00371 0.0037 0.00369 0.00368 0.00367 0.00365
## Cumulative Proportion 0.72391 0.72766 0.73140 0.73513 0.73885 0.74256 0.74627 0.7500 0.75365 0.75733 0.76100 0.76465
## PC169 PC170 PC171 PC172 PC173 PC174 PC175 PC176 PC177 PC178 PC179 PC180
## Standard deviation 0.93500 0.93343 0.93208 0.93200 0.9300 0.9295 0.92698 0.92643 0.92505 0.92385 0.92325 0.92122
## Proportion of Variance 0.00364 0.00363 0.00362 0.00362 0.0036 0.0036 0.00358 0.00358 0.00357 0.00356 0.00355 0.00354
## Cumulative Proportion 0.76829 0.77192 0.77554 0.77916 0.7828 0.7864 0.78994 0.79352 0.79708 0.80064 0.80419 0.80773
## PC181 PC182 PC183 PC184 PC185 PC186 PC187 PC188 PC189 PC190 PC191 PC192
## Standard deviation 0.91894 0.91786 0.9165 0.9160 0.91558 0.91396 0.91183 0.90944 0.90827 0.90721 0.90632 0.90529
## Proportion of Variance 0.00352 0.00351 0.0035 0.0035 0.00349 0.00348 0.00346 0.00345 0.00344 0.00343 0.00342 0.00341
## Cumulative Proportion 0.81125 0.81476 0.8183 0.8217 0.82525 0.82873 0.83219 0.83564 0.83907 0.84250 0.84593 0.84934
## PC193 PC194 PC195 PC196 PC197 PC198 PC199 PC200 PC201 PC202 PC203 PC204
## Standard deviation 0.90457 0.9034 0.90208 0.90105 0.89916 0.89772 0.89656 0.89605 0.89191 0.89167 0.8906 0.88912
## Proportion of Variance 0.00341 0.0034 0.00339 0.00338 0.00337 0.00336 0.00335 0.00335 0.00331 0.00331 0.0033 0.00329
## Cumulative Proportion 0.85275 0.8561 0.85954 0.86292 0.86629 0.86965 0.87300 0.87635 0.87966 0.88297 0.8863 0.88957
## PC205 PC206 PC207 PC208 PC209 PC210 PC211 PC212 PC213 PC214 PC215 PC216
## Standard deviation 0.88740 0.88429 0.88386 0.88233 0.88045 0.87944 0.87867 0.87734 0.8757 0.87283 0.87119 0.86998
## Proportion of Variance 0.00328 0.00326 0.00326 0.00324 0.00323 0.00322 0.00322 0.00321 0.0032 0.00317 0.00316 0.00315
## Cumulative Proportion 0.89285 0.89611 0.89937 0.90261 0.90584 0.90906 0.91228 0.91549 0.9187 0.92186 0.92502 0.92817
## PC217 PC218 PC219 PC220 PC221 PC222 PC223 PC224 PC225 PC226 PC227 PC228
## Standard deviation 0.86891 0.86819 0.86572 0.86341 0.8623 0.85963 0.85747 0.85597 0.85552 0.85423 0.85298 0.85038
## Proportion of Variance 0.00315 0.00314 0.00312 0.00311 0.0031 0.00308 0.00306 0.00305 0.00305 0.00304 0.00303 0.00301
## Cumulative Proportion 0.93132 0.93446 0.93758 0.94069 0.9438 0.94686 0.94993 0.95298 0.95603 0.95907 0.96210 0.96512
## PC229 PC230 PC231 PC232 PC233 PC234 PC235 PC236 PC237 PC238 PC239 PC240
## Standard deviation 0.84687 0.84630 0.84533 0.84209 0.84002 0.83569 0.8336 0.83335 0.82944 0.82661 0.82391 0.8197
## Proportion of Variance 0.00299 0.00298 0.00298 0.00295 0.00294 0.00291 0.0029 0.00289 0.00287 0.00285 0.00283 0.0028
## Cumulative Proportion 0.96810 0.97109 0.97407 0.97702 0.97996 0.98287 0.9858 0.98866 0.99153 0.99437 0.99720 1.0000
#pca.model$rotation
#creating dataset
data.pca = dplyr::select(data,!!label.names) %>%
dplyr::bind_cols(dplyr::select(as.data.frame(pca.model$x)
,!!colnames(pca.model$rotation)[pca.model$pcaSel])
)
data.pca = data[sample(nrow(data.pca)),] # randomly shuffle data
split = sample.split(data.pca[,label.names], SplitRatio = 0.8)
data.train = subset(data.pca, split == TRUE)
data.test = subset(data.pca, split == FALSE)
plot.diagnostics <- function(model, train) {
plot(model)
residuals = resid(model) # Plotted above in plot(lm.out)
r.standard = rstandard(model)
r.student = rstudent(model)
df = data.frame(x=predict(model,train),y=r.student)
p=ggplot(data=df,aes(x=x,y=y)) +
geom_point(color='blue',alpha=0.5,shape=20,size=2) +
geom_hline(yintercept = 0,size=1)+
ylab("Student Residuals") +
xlab("Predicted Values")+
ggtitle("Student Residual Plot")
plot(p)
df = data.frame(x=predict(model,train),y=r.standard)
p=ggplot(data=df,aes(x=x,y=y)) +
geom_point(color='blue',alpha=0.5,shape=20,size=2) +
geom_hline(yintercept = c(-2,0,2),size=1)+
ylab("Student Residuals") +
xlab("Predicted Values")+
ggtitle("Student Residual Plot")
plot(p)
# Histogram
df=data.frame(r.student)
p=ggplot(data=df,aes(r.student)) +
geom_histogram(aes(y=..density..),bins = 50,fill='blue',alpha=0.6) +
stat_function(fun = dnorm, n = 100, args = list(mean = 0, sd = 1)) +
ylab("Density")+
xlab("Studentized Residuals")+
ggtitle("Distribution of Studentized Residuals")
plot(p)
# http://www.stat.columbia.edu/~martin/W2024/R7.pdf
# Influential plots
inf.meas = influence.measures(model)
# print (summary(inf.meas)) # too much data
# Leverage plot
lev = hat(model.matrix(model))
df=tibble::rownames_to_column(as.data.frame(lev),'id')
p=ggplot(data=df,aes(x=as.numeric(id),y=lev)) +
geom_point(color='blue',alpha=0.5,shape=20,size=2) +
ylab('Leverage - check') +
xlab('Index')
plot(p)
# Cook's Distance
cd = cooks.distance(model)
df=tibble::rownames_to_column(as.data.frame(cd),'id')
p=ggplot(data=df,aes(x=as.numeric(id),y=cd)) +
geom_point(color='blue',alpha=0.5,shape=20,size=2) +
geom_text(data=filter(df,cd>15/nrow(train)),aes(label=id),check_overlap=T,size=3,vjust=-.5)+
ylab('Cooks distances') +
geom_hline(yintercept = c(4/nrow(train),0),size=1)+
xlab('Index')
plot(p)
print (paste("Number of data points that have Cook's D > 4/n: ", length(cd[cd > 4/nrow(train)]), sep = ""))
print (paste("Number of data points that have Cook's D > 1: ", length(cd[cd > 1]), sep = ""))
return(cd)
}
# function to set up random seeds
# Based on http://jaehyeon-kim.github.io/2015/05/Setup-Random-Seeds-on-Caret-Package.html
setCaretSeeds <- function(method = "cv", numbers = 1, repeats = 1, tunes = NULL, seed = 1701) {
#B is the number of resamples and integer vector of M (numbers + tune length if any)
B <- if (method == "cv") numbers
else if(method == "repeatedcv") numbers * repeats
else NULL
if(is.null(length)) {
seeds <- NULL
} else {
set.seed(seed = seed)
seeds <- vector(mode = "list", length = B)
seeds <- lapply(seeds, function(x) sample.int(n = 1000000
, size = numbers + ifelse(is.null(tunes), 0, tunes)))
seeds[[length(seeds) + 1]] <- sample.int(n = 1000000, size = 1)
}
# return seeds
seeds
}
train.caret.glmselect = function(formula, data, method
,subopt = NULL, feature.names
, train.control = NULL, tune.grid = NULL, pre.proc = NULL){
if(is.null(train.control)){
train.control <- trainControl(method = "cv"
,number = 10
,seeds = setCaretSeeds(method = "cv"
, numbers = 10
, seed = 1701)
,search = "grid"
,verboseIter = TRUE
,allowParallel = TRUE
)
}
if(is.null(tune.grid)){
if (method == 'leapForward' | method == 'leapBackward' | method == 'leapSeq'){
tune.grid = data.frame(nvmax = 1:length(feature.names))
}
if (method == 'glmnet' && subopt == 'LASSO'){
# Will only show 1 Lambda value during training, but that is OK
# https://stackoverflow.com/questions/47526544/why-need-to-tune-lambda-with-carettrain-method-glmnet-and-cv-glmnet
# Another option for LASSO is this: https://github.com/topepo/caret/blob/master/RegressionTests/Code/lasso.R
lambda = 10^seq(-2,0, length =100)
alpha = c(1)
tune.grid = expand.grid(alpha = alpha,lambda = lambda)
}
if (method == 'lars'){
# https://github.com/topepo/caret/blob/master/RegressionTests/Code/lars.R
fraction = seq(0, 1, length = 100)
tune.grid = expand.grid(fraction = fraction)
pre.proc = c("center", "scale")
}
}
# http://sshaikh.org/2015/05/06/parallelize-machine-learning-in-r-with-multi-core-cpus/
cl <- makeCluster(ceiling(detectCores()*0.85)) # use 75% of cores only, leave rest for other tasks
registerDoParallel(cl)
set.seed(1)
# note that the seed has to actually be set just before this function is called
# settign is above just not ensure reproducibility for some reason
model.caret <- caret::train(formula
, data = data
, method = method
, tuneGrid = tune.grid
, trControl = train.control
, preProc = pre.proc
)
stopCluster(cl)
registerDoSEQ() # register sequential engine in case you are not using this function anymore
if (method == 'leapForward' | method == 'leapBackward' | method == 'leapSeq'){
print("All models results")
print(model.caret$results) # all model results
print("Best Model")
print(model.caret$bestTune) # best model
model = model.caret$finalModel
# Metrics Plot
dataPlot = model.caret$results %>%
gather(key='metric',value='value',-nvmax) %>%
dplyr::filter(metric %in% c('MAE','RMSE','Rsquared'))
metricsPlot = ggplot(data=dataPlot,aes(x=nvmax,y=value) ) +
geom_line(color='lightblue4') +
geom_point(color='blue',alpha=0.7,size=.9) +
facet_wrap(~metric,ncol=2,scales='free_y')+
theme_light()
plot(metricsPlot)
# Residuals Plot
# leap function does not support studentized residuals
dataPlot=data.frame(pred=predict(model.caret,data),res=resid(model.caret))
residPlot = ggplot(dataPlot,aes(x=pred,y=res)) +
geom_point(color='light blue',alpha=0.7) +
geom_smooth(method="lm")+
theme_light()
plot(residPlot)
residHistogram = ggplot(dataPlot,aes(x=res)) +
geom_histogram(aes(y=..density..),fill='light blue',alpha=1) +
#geom_density(color='lightblue4') +
stat_function(fun = dnorm, n = 100, args = list(mean = mean(dataPlot$res)
, sd = sd(dataPlot$res)),color='lightblue4')
theme_light()
plot(residHistogram)
id = rownames(model.caret$bestTune)
# Provides the coefficients of the best model
# regsubsets doens return a full model (see documentation of regsubset), so we need to recalcualte themodel
# https://stackoverflow.com/questions/13063762/how-to-obtain-a-lm-object-from-regsubsets
print("Coefficients of final model:")
coefs <- coef(model, id=id)
#calculate the model to the the coef intervals
nams <- names(coefs)
nams <- nams[!nams %in% "(Intercept)"]
response <- as.character(formula[[2]])
form <- as.formula(paste(response, paste(nams, collapse = " + "), sep = " ~ "))
mod <- lm(form, data = data)
#coefs
#coef(mod)
print(car::Confint(mod))
return(list(model = model,id = id, residPlot = residPlot, residHistogram=residHistogram
,modelLM=mod))
}
if (method == 'glmnet' && subopt == 'LASSO'){
print(model.caret)
print(plot(model.caret))
print(model.caret$bestTune)
print(model.caret$results)
model=model.caret$finalModel
# Metrics Plot
dataPlot = model.caret$results %>%
gather(key='metric',value='value',-lambda) %>%
dplyr::filter(metric %in% c('MAE','RMSE','Rsquared'))
metricsPlot = ggplot(data=dataPlot,aes(x=lambda,y=value) ) +
geom_line(color='lightblue4') +
geom_point(color='blue',alpha=0.7,size=.9) +
facet_wrap(~metric,ncol=2,scales='free_y')+
theme_light()
plot(metricsPlot)
# Residuals Plot
dataPlot=data.frame(pred=predict(model.caret,data),res=resid(model.caret))
residPlot = ggplot(dataPlot,aes(x=pred,y=res)) +
geom_point(color='light blue',alpha=0.7) +
geom_smooth(method="lm")+
theme_light()
plot(residPlot)
residHistogram = ggplot(dataPlot,aes(x=res)) +
geom_histogram(aes(y=..density..),fill='light blue',alpha=1) +
#geom_density(color='lightblue4') +
stat_function(fun = dnorm, n = 100, args = list(mean = mean(dataPlot$res)
, sd = sd(dataPlot$res)),color='lightblue4')
theme_light()
plot(residHistogram)
print("Coefficients")
#no interval for glmnet: https://stackoverflow.com/questions/39750965/confidence-intervals-for-ridge-regression
t=coef(model,s=model.caret$bestTune$lambda)
model.coef = t[which(t[,1]!=0),]
print(as.data.frame(model.coef))
id = NULL # not really needed but added for consistency
return(list(model = model.caret,id = id, residPlot = residPlot, metricsPlot=metricsPlot ))
}
if (method == 'lars'){
print(model.caret)
print(plot(model.caret))
print(model.caret$bestTune)
# Metrics Plot
dataPlot = model.caret$results %>%
gather(key='metric',value='value',-fraction) %>%
dplyr::filter(metric %in% c('MAE','RMSE','Rsquared'))
metricsPlot = ggplot(data=dataPlot,aes(x=fraction,y=value) ) +
geom_line(color='lightblue4') +
geom_point(color='blue',alpha=0.7,size=.9) +
facet_wrap(~metric,ncol=2,scales='free_y')+
theme_light()
plot(metricsPlot)
# Residuals Plot
dataPlot=data.frame(pred=predict(model.caret,data),res=resid(model.caret))
residPlot = ggplot(dataPlot,aes(x=pred,y=res)) +
geom_point(color='light blue',alpha=0.7) +
geom_smooth(method="lm")+
theme_light()
plot(residPlot)
residHistogram = ggplot(dataPlot,aes(x=res)) +
geom_histogram(aes(y=..density..),fill='light blue',alpha=1) +
#geom_density(color='lightblue4') +
stat_function(fun = dnorm, n = 100, args = list(mean = mean(dataPlot$res)
, sd = sd(dataPlot$res)),color='lightblue4')
theme_light()
plot(residHistogram)
print("Coefficients")
t=coef(model.caret$finalModel,s=model.caret$bestTune$fraction,mode='fraction')
model.coef = t[which(t!=0)]
print(model.coef)
id = NULL # not really needed but added for consistency
return(list(model = model.caret,id = id, residPlot = residPlot, residHistogram=residHistogram))
}
}
# https://stackoverflow.com/questions/48265743/linear-model-subset-selection-goodness-of-fit-with-k-fold-cross-validation
# changed slightly since call[[2]] was just returning "formula" without actually returnign the value in formula
predict.regsubsets <- function(object, newdata, id, formula, ...) {
#form <- as.formula(object$call[[2]])
mat <- model.matrix(formula, newdata) # adds intercept and expands any interaction terms
coefi <- coef(object, id = id)
xvars <- names(coefi)
return(mat[,xvars]%*%coefi)
}
test.model = function(model, test, level=0.95
,draw.limits = FALSE, good = 0.1, ok = 0.15
,method = NULL, subopt = NULL
,id = NULL, formula, feature.names, label.names
,transformation = NULL){
## if using caret for glm select equivalent functionality,
## need to pass formula (full is ok as it will select subset of variables from there)
if (is.null(method)){
pred = predict(model, newdata=test, interval="confidence", level = level)
}
if (method == 'leapForward' | method == 'leapBackward' | method == 'leapSeq'){
pred = predict.regsubsets(model, newdata = test, id = id, formula = formula)
}
if (method == 'glmnet' && subopt == 'LASSO'){
xtest = as.matrix(test[,feature.names])
pred=as.data.frame(predict(model, xtest))
}
if (method == 'lars'){
pred=as.data.frame(predict(model, newdata = test))
}
# Summary of predicted values
print ("Summary of predicted values: ")
print(summary(pred[,1]))
test.mse = mean((test[,label.names]-pred[,1])^2)
print (paste(method, subopt, "Test MSE:", test.mse, sep=" "))
if(log.pred == TRUE || norm.pred == TRUE){
# plot transformewd comparison first
df=data.frame(x=test[,label.names],y=pred[,1])
ggplot(df,aes(x=x,y=y)) +
geom_point(color='blue',alpha=0.5,shape=20,size=2) +
geom_abline(slope=1,intercept=0,color='black',size=1) +
#scale_y_continuous(limits=c(min(df),max(df)))+
xlab("Actual (Transformed)")+
ylab("Predicted (Transformed)")
}
if (log.pred == FALSE && norm.pred == FALSE){
x = test[,label.names]
y = pred[,1]
}
if (log.pred == TRUE){
x = 10^test[,label.names]
y = 10^pred[,1]
}
if (norm.pred == TRUE){
x = predict(transformation, test[,label.names], inverse = TRUE)
y = predict(transformation, pred[,1], inverse = TRUE)
}
df=data.frame(x,y)
ggplot(df,aes(x,y)) +
geom_point(color='blue',alpha=0.5,shape=20,size=2) +
geom_abline(slope=c(1+good,1-good,1+ok,1-ok)
,intercept=rep(0,4),color=c('dark green','dark green','dark red','dark red'),size=1,alpha=0.8) +
#scale_y_continuous(limits=c(min(df),max(df)))+
xlab("Actual")+
ylab("Predicted")
}
n <- names(data.train)
formula <- as.formula(paste(paste(n[n %in% label.names], collapse = " + ")
," ~", paste(n[!n %in% label.names], collapse = " + ")))
grand.mean.formula = as.formula(paste(paste(n[n %in% label.names], collapse = " + ")," ~ 1"))
print(formula)
## y3.log ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 +
## x12 + x13 + x14 + x15 + x16 + x17 + x19 + x20 + x21 + x22 +
## x23 + stat1 + stat2 + stat3 + stat4 + stat5 + stat6 + stat7 +
## stat8 + stat9 + stat10 + stat11 + stat12 + stat13 + stat14 +
## stat15 + stat16 + stat17 + stat18 + stat19 + stat20 + stat21 +
## stat22 + stat23 + stat24 + stat25 + stat26 + stat27 + stat28 +
## stat29 + stat30 + stat31 + stat32 + stat33 + stat34 + stat35 +
## stat36 + stat37 + stat38 + stat39 + stat40 + stat41 + stat42 +
## stat43 + stat44 + stat45 + stat46 + stat47 + stat48 + stat49 +
## stat50 + stat51 + stat52 + stat53 + stat54 + stat55 + stat56 +
## stat57 + stat58 + stat59 + stat60 + stat61 + stat62 + stat63 +
## stat64 + stat65 + stat66 + stat67 + stat68 + stat69 + stat70 +
## stat71 + stat72 + stat73 + stat74 + stat75 + stat76 + stat77 +
## stat78 + stat79 + stat80 + stat81 + stat82 + stat83 + stat84 +
## stat85 + stat86 + stat87 + stat88 + stat89 + stat90 + stat91 +
## stat92 + stat93 + stat94 + stat95 + stat96 + stat97 + stat98 +
## stat99 + stat100 + stat101 + stat102 + stat103 + stat104 +
## stat105 + stat106 + stat107 + stat108 + stat109 + stat110 +
## stat111 + stat112 + stat113 + stat114 + stat115 + stat116 +
## stat117 + stat118 + stat119 + stat120 + stat121 + stat122 +
## stat123 + stat124 + stat125 + stat126 + stat127 + stat128 +
## stat129 + stat130 + stat131 + stat132 + stat133 + stat134 +
## stat135 + stat136 + stat137 + stat138 + stat139 + stat140 +
## stat141 + stat142 + stat143 + stat144 + stat145 + stat146 +
## stat147 + stat148 + stat149 + stat150 + stat151 + stat152 +
## stat153 + stat154 + stat155 + stat156 + stat157 + stat158 +
## stat159 + stat160 + stat161 + stat162 + stat163 + stat164 +
## stat165 + stat166 + stat167 + stat168 + stat169 + stat170 +
## stat171 + stat172 + stat173 + stat174 + stat175 + stat176 +
## stat177 + stat178 + stat179 + stat180 + stat181 + stat182 +
## stat183 + stat184 + stat185 + stat186 + stat187 + stat188 +
## stat189 + stat190 + stat191 + stat192 + stat193 + stat194 +
## stat195 + stat196 + stat197 + stat198 + stat199 + stat200 +
## stat201 + stat202 + stat203 + stat204 + stat205 + stat206 +
## stat207 + stat208 + stat209 + stat210 + stat211 + stat212 +
## stat213 + stat214 + stat215 + stat216 + stat217 + x18.sqrt
print(grand.mean.formula)
## y3.log ~ 1
# Update feature.names because we may have transformed some features
feature.names = n[!n %in% label.names]
model.full = lm(formula , data.train)
summary(model.full)
##
## Call:
## lm(formula = formula, data = data.train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.078771 -0.020685 -0.004824 0.016665 0.188185
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.964e+00 9.566e-03 205.340 < 2e-16 ***
## x1 -7.881e-04 6.604e-04 -1.193 0.232807
## x2 3.214e-04 4.219e-04 0.762 0.446150
## x3 1.699e-05 1.152e-04 0.147 0.882801
## x4 -4.950e-05 9.054e-06 -5.467 4.77e-08 ***
## x5 3.169e-04 2.984e-04 1.062 0.288158
## x6 3.704e-04 6.024e-04 0.615 0.538736
## x7 1.047e-02 6.452e-04 16.224 < 2e-16 ***
## x8 4.250e-04 1.491e-04 2.850 0.004382 **
## x9 2.970e-03 3.329e-04 8.922 < 2e-16 ***
## x10 1.194e-03 3.094e-04 3.858 0.000116 ***
## x11 2.413e+05 7.405e+04 3.259 0.001127 **
## x12 -1.188e-04 1.890e-04 -0.629 0.529440
## x13 7.212e-05 7.593e-05 0.950 0.342252
## x14 -6.318e-04 3.271e-04 -1.932 0.053452 .
## x15 -1.562e-04 3.107e-04 -0.503 0.615143
## x16 1.192e-03 2.155e-04 5.530 3.35e-08 ***
## x17 1.559e-03 3.290e-04 4.738 2.21e-06 ***
## x19 3.528e-04 1.669e-04 2.114 0.034567 *
## x20 5.552e-05 1.161e-03 0.048 0.961869
## x21 1.311e-04 4.243e-05 3.090 0.002011 **
## x22 -5.455e-04 3.481e-04 -1.567 0.117164
## x23 -1.101e-04 3.309e-04 -0.333 0.739392
## stat1 -2.551e-04 2.507e-04 -1.017 0.308980
## stat2 2.594e-04 2.487e-04 1.043 0.296883
## stat3 2.070e-04 2.529e-04 0.819 0.413077
## stat4 -5.932e-04 2.515e-04 -2.358 0.018395 *
## stat5 -1.697e-04 2.515e-04 -0.675 0.499912
## stat6 -3.506e-05 2.516e-04 -0.139 0.889187
## stat7 -8.112e-05 2.512e-04 -0.323 0.746756
## stat8 9.034e-05 2.496e-04 0.362 0.717440
## stat9 2.938e-05 2.502e-04 0.117 0.906547
## stat10 -1.259e-04 2.511e-04 -0.502 0.616009
## stat11 -3.900e-04 2.522e-04 -1.546 0.122140
## stat12 3.029e-04 2.502e-04 1.210 0.226208
## stat13 -3.328e-04 2.490e-04 -1.337 0.181366
## stat14 -8.853e-04 2.487e-04 -3.560 0.000374 ***
## stat15 -4.498e-04 2.477e-04 -1.816 0.069385 .
## stat16 -5.403e-05 2.504e-04 -0.216 0.829188
## stat17 1.212e-04 2.486e-04 0.487 0.626013
## stat18 -9.120e-05 2.497e-04 -0.365 0.714939
## stat19 -4.284e-05 2.501e-04 -0.171 0.864003
## stat20 -3.718e-04 2.493e-04 -1.491 0.135953
## stat21 -5.269e-06 2.507e-04 -0.021 0.983234
## stat22 -6.440e-04 2.511e-04 -2.565 0.010353 *
## stat23 5.619e-04 2.493e-04 2.254 0.024221 *
## stat24 -6.242e-04 2.508e-04 -2.489 0.012842 *
## stat25 -3.494e-04 2.504e-04 -1.396 0.162842
## stat26 -1.109e-04 2.495e-04 -0.445 0.656619
## stat27 -1.893e-05 2.506e-04 -0.076 0.939771
## stat28 -8.657e-05 2.498e-04 -0.347 0.728970
## stat29 9.990e-05 2.514e-04 0.397 0.691116
## stat30 2.255e-04 2.519e-04 0.895 0.370733
## stat31 -4.350e-05 2.518e-04 -0.173 0.862826
## stat32 -4.392e-05 2.521e-04 -0.174 0.861668
## stat33 -2.208e-04 2.482e-04 -0.890 0.373720
## stat34 1.905e-04 2.490e-04 0.765 0.444304
## stat35 -3.215e-04 2.514e-04 -1.279 0.200880
## stat36 4.466e-05 2.491e-04 0.179 0.857706
## stat37 -2.649e-04 2.511e-04 -1.055 0.291378
## stat38 4.659e-04 2.503e-04 1.861 0.062763 .
## stat39 -5.366e-05 2.502e-04 -0.214 0.830213
## stat40 2.115e-04 2.505e-04 0.844 0.398606
## stat41 -3.655e-04 2.487e-04 -1.470 0.141748
## stat42 -8.840e-05 2.495e-04 -0.354 0.723170
## stat43 -2.102e-05 2.507e-04 -0.084 0.933210
## stat44 1.136e-04 2.483e-04 0.458 0.647259
## stat45 -1.405e-04 2.482e-04 -0.566 0.571372
## stat46 2.491e-04 2.502e-04 0.996 0.319487
## stat47 4.076e-04 2.513e-04 1.622 0.104942
## stat48 1.734e-04 2.509e-04 0.691 0.489638
## stat49 1.840e-04 2.489e-04 0.739 0.459772
## stat50 1.412e-04 2.476e-04 0.570 0.568488
## stat51 1.981e-04 2.516e-04 0.788 0.430950
## stat52 -1.154e-05 2.509e-04 -0.046 0.963308
## stat53 -2.328e-04 2.535e-04 -0.919 0.358388
## stat54 -3.660e-04 2.516e-04 -1.454 0.145894
## stat55 3.233e-04 2.471e-04 1.308 0.190854
## stat56 -4.260e-05 2.517e-04 -0.169 0.865617
## stat57 2.650e-04 2.473e-04 1.072 0.283972
## stat58 -1.319e-04 2.479e-04 -0.532 0.594677
## stat59 2.886e-04 2.502e-04 1.154 0.248694
## stat60 3.786e-04 2.501e-04 1.514 0.130195
## stat61 1.876e-04 2.514e-04 0.746 0.455513
## stat62 -1.953e-04 2.501e-04 -0.781 0.435034
## stat63 1.819e-04 2.493e-04 0.730 0.465531
## stat64 -1.214e-04 2.482e-04 -0.489 0.624658
## stat65 -3.355e-04 2.505e-04 -1.339 0.180518
## stat66 1.313e-04 2.530e-04 0.519 0.603696
## stat67 1.932e-05 2.521e-04 0.077 0.938923
## stat68 -9.517e-05 2.506e-04 -0.380 0.704094
## stat69 -4.979e-05 2.506e-04 -0.199 0.842529
## stat70 3.104e-04 2.492e-04 1.246 0.212924
## stat71 4.198e-04 2.487e-04 1.688 0.091511 .
## stat72 2.367e-04 2.515e-04 0.941 0.346688
## stat73 4.428e-04 2.523e-04 1.755 0.079291 .
## stat74 -1.526e-04 2.501e-04 -0.610 0.541695
## stat75 -1.198e-05 2.517e-04 -0.048 0.962059
## stat76 1.488e-04 2.512e-04 0.592 0.553580
## stat77 -1.562e-04 2.500e-04 -0.625 0.532166
## stat78 -1.467e-05 2.499e-04 -0.059 0.953198
## stat79 -3.120e-04 2.511e-04 -1.243 0.214068
## stat80 2.500e-04 2.520e-04 0.992 0.321378
## stat81 4.596e-04 2.508e-04 1.833 0.066885 .
## stat82 4.086e-04 2.500e-04 1.634 0.102318
## stat83 -4.227e-07 2.505e-04 -0.002 0.998654
## stat84 -1.590e-05 2.502e-04 -0.064 0.949318
## stat85 2.625e-04 2.495e-04 1.052 0.292835
## stat86 1.571e-04 2.506e-04 0.627 0.530716
## stat87 -4.750e-04 2.515e-04 -1.889 0.058986 .
## stat88 -2.364e-05 2.471e-04 -0.096 0.923796
## stat89 -2.020e-04 2.488e-04 -0.812 0.416835
## stat90 -1.437e-04 2.520e-04 -0.570 0.568433
## stat91 -4.052e-04 2.498e-04 -1.622 0.104791
## stat92 -2.702e-04 2.507e-04 -1.078 0.281245
## stat93 -2.380e-04 2.533e-04 -0.939 0.347587
## stat94 -1.309e-05 2.497e-04 -0.052 0.958172
## stat95 -3.780e-05 2.487e-04 -0.152 0.879184
## stat96 -1.249e-04 2.497e-04 -0.500 0.616984
## stat97 6.808e-07 2.488e-04 0.003 0.997817
## stat98 3.571e-03 2.464e-04 14.492 < 2e-16 ***
## stat99 2.916e-04 2.513e-04 1.160 0.246009
## stat100 2.901e-04 2.510e-04 1.156 0.247903
## stat101 -2.470e-04 2.519e-04 -0.981 0.326746
## stat102 3.412e-05 2.508e-04 0.136 0.891786
## stat103 -3.260e-04 2.534e-04 -1.286 0.198342
## stat104 -3.365e-04 2.504e-04 -1.344 0.178942
## stat105 3.342e-05 2.475e-04 0.135 0.892576
## stat106 -3.857e-04 2.490e-04 -1.549 0.121426
## stat107 5.462e-05 2.481e-04 0.220 0.825751
## stat108 -1.591e-04 2.507e-04 -0.635 0.525771
## stat109 -4.104e-05 2.483e-04 -0.165 0.868739
## stat110 -3.279e-03 2.497e-04 -13.129 < 2e-16 ***
## stat111 -2.699e-04 2.498e-04 -1.081 0.279915
## stat112 -1.459e-04 2.506e-04 -0.582 0.560384
## stat113 -2.215e-05 2.506e-04 -0.088 0.929571
## stat114 8.477e-05 2.501e-04 0.339 0.734646
## stat115 3.318e-04 2.483e-04 1.336 0.181506
## stat116 3.288e-04 2.495e-04 1.318 0.187556
## stat117 1.414e-04 2.523e-04 0.560 0.575187
## stat118 -3.053e-04 2.477e-04 -1.232 0.217881
## stat119 3.585e-05 2.494e-04 0.144 0.885717
## stat120 2.402e-04 2.476e-04 0.970 0.331944
## stat121 1.651e-05 2.505e-04 0.066 0.947457
## stat122 -8.583e-05 2.481e-04 -0.346 0.729381
## stat123 -1.976e-04 2.528e-04 -0.782 0.434468
## stat124 -3.228e-04 2.505e-04 -1.289 0.197614
## stat125 2.131e-04 2.499e-04 0.853 0.393653
## stat126 9.793e-05 2.498e-04 0.392 0.695086
## stat127 1.941e-04 2.500e-04 0.776 0.437571
## stat128 2.177e-04 2.484e-04 0.876 0.380849
## stat129 6.135e-05 2.487e-04 0.247 0.805136
## stat130 7.047e-05 2.492e-04 0.283 0.777372
## stat131 1.485e-04 2.514e-04 0.591 0.554600
## stat132 -3.355e-05 2.469e-04 -0.136 0.891926
## stat133 1.602e-04 2.501e-04 0.640 0.521958
## stat134 -2.611e-04 2.500e-04 -1.045 0.296260
## stat135 -1.904e-04 2.508e-04 -0.759 0.447754
## stat136 -1.372e-04 2.517e-04 -0.545 0.585562
## stat137 -1.395e-05 2.475e-04 -0.056 0.955051
## stat138 -7.305e-05 2.499e-04 -0.292 0.770058
## stat139 1.196e-04 2.507e-04 0.477 0.633402
## stat140 2.776e-05 2.485e-04 0.112 0.911047
## stat141 6.570e-05 2.493e-04 0.264 0.792149
## stat142 -5.467e-06 2.520e-04 -0.022 0.982689
## stat143 3.818e-05 2.502e-04 0.153 0.878718
## stat144 2.517e-04 2.488e-04 1.012 0.311763
## stat145 2.214e-05 2.521e-04 0.088 0.930025
## stat146 -5.776e-04 2.521e-04 -2.292 0.021958 *
## stat147 -3.578e-04 2.519e-04 -1.420 0.155533
## stat148 -3.591e-04 2.475e-04 -1.451 0.146896
## stat149 -6.710e-04 2.510e-04 -2.674 0.007529 **
## stat150 1.596e-05 2.520e-04 0.063 0.949488
## stat151 -8.240e-06 2.509e-04 -0.033 0.973804
## stat152 -1.251e-04 2.478e-04 -0.505 0.613719
## stat153 1.497e-04 2.539e-04 0.589 0.555641
## stat154 3.863e-05 2.525e-04 0.153 0.878405
## stat155 -1.531e-04 2.481e-04 -0.617 0.537060
## stat156 4.193e-04 2.530e-04 1.657 0.097529 .
## stat157 -1.013e-04 2.497e-04 -0.406 0.684874
## stat158 -2.168e-05 2.527e-04 -0.086 0.931635
## stat159 4.147e-05 2.491e-04 0.167 0.867759
## stat160 6.068e-05 2.516e-04 0.241 0.809449
## stat161 3.639e-04 2.511e-04 1.450 0.147251
## stat162 1.986e-05 2.481e-04 0.080 0.936198
## stat163 9.961e-05 2.526e-04 0.394 0.693331
## stat164 2.330e-04 2.524e-04 0.923 0.356012
## stat165 -1.572e-04 2.490e-04 -0.631 0.527787
## stat166 -3.009e-04 2.473e-04 -1.217 0.223703
## stat167 -2.435e-04 2.504e-04 -0.972 0.330931
## stat168 -2.517e-04 2.487e-04 -1.012 0.311443
## stat169 -3.069e-05 2.494e-04 -0.123 0.902076
## stat170 -3.340e-04 2.503e-04 -1.334 0.182138
## stat171 -1.930e-05 2.527e-04 -0.076 0.939133
## stat172 3.486e-04 2.472e-04 1.410 0.158545
## stat173 -2.698e-04 2.519e-04 -1.071 0.284185
## stat174 -5.704e-06 2.507e-04 -0.023 0.981851
## stat175 -4.504e-04 2.498e-04 -1.803 0.071423 .
## stat176 3.239e-04 2.500e-04 1.296 0.195174
## stat177 -1.167e-04 2.510e-04 -0.465 0.641863
## stat178 -1.731e-04 2.532e-04 -0.684 0.494243
## stat179 -6.041e-05 2.486e-04 -0.243 0.808012
## stat180 -2.427e-04 2.485e-04 -0.977 0.328742
## stat181 2.965e-04 2.506e-04 1.183 0.236875
## stat182 1.323e-04 2.512e-04 0.527 0.598317
## stat183 1.959e-04 2.489e-04 0.787 0.431268
## stat184 3.818e-05 2.511e-04 0.152 0.879153
## stat185 -1.631e-04 2.470e-04 -0.660 0.509177
## stat186 -9.497e-05 2.524e-04 -0.376 0.706749
## stat187 -3.164e-04 2.496e-04 -1.268 0.204967
## stat188 1.235e-04 2.498e-04 0.494 0.621158
## stat189 1.151e-04 2.520e-04 0.457 0.647973
## stat190 2.023e-05 2.486e-04 0.081 0.935143
## stat191 -3.289e-04 2.510e-04 -1.311 0.190034
## stat192 5.692e-05 2.538e-04 0.224 0.822590
## stat193 7.038e-05 2.525e-04 0.279 0.780504
## stat194 9.785e-05 2.492e-04 0.393 0.694641
## stat195 4.902e-04 2.500e-04 1.961 0.049924 *
## stat196 -2.333e-04 2.534e-04 -0.921 0.357135
## stat197 -6.167e-05 2.468e-04 -0.250 0.802667
## stat198 -2.178e-04 2.521e-04 -0.864 0.387591
## stat199 2.707e-04 2.482e-04 1.091 0.275470
## stat200 -3.406e-04 2.479e-04 -1.374 0.169499
## stat201 -1.174e-04 2.485e-04 -0.473 0.636528
## stat202 -2.160e-04 2.537e-04 -0.851 0.394620
## stat203 -1.607e-04 2.489e-04 -0.646 0.518378
## stat204 -4.771e-04 2.488e-04 -1.918 0.055227 .
## stat205 -8.357e-05 2.485e-04 -0.336 0.736651
## stat206 -1.145e-04 2.510e-04 -0.456 0.648256
## stat207 3.794e-04 2.499e-04 1.518 0.129005
## stat208 7.217e-05 2.506e-04 0.288 0.773327
## stat209 -4.947e-05 2.493e-04 -0.198 0.842719
## stat210 -2.297e-04 2.519e-04 -0.912 0.361943
## stat211 -1.669e-04 2.512e-04 -0.664 0.506601
## stat212 -4.844e-05 2.509e-04 -0.193 0.846906
## stat213 -2.544e-04 2.511e-04 -1.013 0.311034
## stat214 -3.319e-04 2.506e-04 -1.325 0.185352
## stat215 -3.456e-04 2.505e-04 -1.380 0.167789
## stat216 -7.531e-05 2.510e-04 -0.300 0.764140
## stat217 2.131e-04 2.505e-04 0.851 0.395025
## x18.sqrt 2.654e-02 9.497e-04 27.948 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03166 on 5343 degrees of freedom
## Multiple R-squared: 0.2639, Adjusted R-squared: 0.2308
## F-statistic: 7.981 on 240 and 5343 DF, p-value: < 2.2e-16
cd.full = plot.diagnostics(model=model.full, train=data.train)
## [1] "Number of data points that have Cook's D > 4/n: 290"
## [1] "Number of data points that have Cook's D > 1: 0"
high.cd = names(cd.full[cd.full > 4/nrow(data.train)])
#save dataset with high.cd flagged
t = data.train %>%
rownames_to_column() %>%
mutate(high.cd = ifelse(rowname %in% high.cd,1,0))
#write.csv(t,file='data_high_cd_flag.csv',row.names = F)
###
data.train2 = data.train[!(rownames(data.train)) %in% high.cd,]
model.full2 = lm(formula , data.train2)
summary(model.full2)
##
## Call:
## lm(formula = formula, data = data.train2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.060310 -0.017361 -0.002699 0.016784 0.069654
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.954e+00 7.807e-03 250.340 < 2e-16 ***
## x1 -3.136e-04 5.384e-04 -0.582 0.560265
## x2 3.169e-04 3.434e-04 0.923 0.356109
## x3 5.197e-05 9.348e-05 0.556 0.578284
## x4 -5.738e-05 7.396e-06 -7.758 1.03e-14 ***
## x5 5.671e-04 2.427e-04 2.336 0.019514 *
## x6 1.564e-04 4.906e-04 0.319 0.749869
## x7 1.132e-02 5.253e-04 21.554 < 2e-16 ***
## x8 4.704e-04 1.215e-04 3.872 0.000109 ***
## x9 3.105e-03 2.704e-04 11.482 < 2e-16 ***
## x10 1.619e-03 2.528e-04 6.404 1.65e-10 ***
## x11 2.355e+05 6.041e+04 3.899 9.80e-05 ***
## x12 6.099e-05 1.535e-04 0.397 0.691244
## x13 1.454e-04 6.195e-05 2.348 0.018924 *
## x14 -3.679e-04 2.660e-04 -1.383 0.166636
## x15 -1.277e-04 2.528e-04 -0.505 0.613624
## x16 1.184e-03 1.754e-04 6.751 1.63e-11 ***
## x17 1.492e-03 2.686e-04 5.557 2.89e-08 ***
## x19 2.109e-04 1.360e-04 1.551 0.121080
## x20 -2.583e-04 9.469e-04 -0.273 0.785059
## x21 1.274e-04 3.460e-05 3.683 0.000233 ***
## x22 -6.687e-04 2.827e-04 -2.365 0.018074 *
## x23 -5.181e-05 2.700e-04 -0.192 0.847843
## stat1 -3.483e-04 2.042e-04 -1.706 0.088074 .
## stat2 3.549e-04 2.023e-04 1.755 0.079405 .
## stat3 2.952e-04 2.062e-04 1.432 0.152263
## stat4 -6.610e-04 2.053e-04 -3.219 0.001293 **
## stat5 -1.258e-04 2.054e-04 -0.612 0.540298
## stat6 1.951e-05 2.051e-04 0.095 0.924250
## stat7 -1.804e-04 2.040e-04 -0.884 0.376721
## stat8 -2.849e-05 2.029e-04 -0.140 0.888325
## stat9 -8.125e-05 2.039e-04 -0.398 0.690297
## stat10 -1.283e-04 2.039e-04 -0.629 0.529236
## stat11 -5.274e-04 2.054e-04 -2.568 0.010267 *
## stat12 2.050e-04 2.037e-04 1.006 0.314297
## stat13 -3.620e-04 2.023e-04 -1.789 0.073616 .
## stat14 -1.084e-03 2.024e-04 -5.357 8.85e-08 ***
## stat15 -6.300e-04 2.020e-04 -3.119 0.001822 **
## stat16 -2.151e-04 2.038e-04 -1.055 0.291296
## stat17 -7.841e-05 2.026e-04 -0.387 0.698680
## stat18 2.324e-05 2.032e-04 0.114 0.908981
## stat19 -3.200e-05 2.043e-04 -0.157 0.875530
## stat20 -1.811e-05 2.031e-04 -0.089 0.928968
## stat21 -1.500e-05 2.043e-04 -0.073 0.941448
## stat22 -4.380e-04 2.043e-04 -2.144 0.032088 *
## stat23 4.724e-04 2.035e-04 2.322 0.020290 *
## stat24 -5.808e-04 2.044e-04 -2.842 0.004502 **
## stat25 -3.175e-04 2.039e-04 -1.557 0.119534
## stat26 -1.238e-04 2.032e-04 -0.610 0.542170
## stat27 -1.701e-05 2.045e-04 -0.083 0.933728
## stat28 -1.798e-04 2.035e-04 -0.883 0.377049
## stat29 8.800e-05 2.048e-04 0.430 0.667429
## stat30 8.695e-05 2.049e-04 0.424 0.671263
## stat31 -7.657e-06 2.048e-04 -0.037 0.970173
## stat32 -2.766e-05 2.056e-04 -0.135 0.892988
## stat33 -5.570e-05 2.024e-04 -0.275 0.783148
## stat34 4.537e-04 2.028e-04 2.237 0.025343 *
## stat35 -4.589e-04 2.051e-04 -2.238 0.025286 *
## stat36 2.120e-05 2.033e-04 0.104 0.916966
## stat37 3.756e-05 2.044e-04 0.184 0.854218
## stat38 5.286e-04 2.032e-04 2.602 0.009292 **
## stat39 -2.572e-04 2.032e-04 -1.266 0.205653
## stat40 2.407e-04 2.047e-04 1.176 0.239657
## stat41 -4.155e-04 2.024e-04 -2.053 0.040165 *
## stat42 -1.552e-05 2.035e-04 -0.076 0.939210
## stat43 -2.262e-05 2.043e-04 -0.111 0.911850
## stat44 9.389e-05 2.027e-04 0.463 0.643257
## stat45 -4.274e-05 2.023e-04 -0.211 0.832667
## stat46 2.326e-06 2.041e-04 0.011 0.990910
## stat47 3.359e-04 2.045e-04 1.643 0.100482
## stat48 1.727e-04 2.041e-04 0.846 0.397678
## stat49 -1.611e-04 2.027e-04 -0.795 0.426603
## stat50 2.343e-04 2.019e-04 1.160 0.245954
## stat51 4.254e-05 2.050e-04 0.207 0.835629
## stat52 9.963e-05 2.046e-04 0.487 0.626386
## stat53 -2.133e-04 2.064e-04 -1.034 0.301256
## stat54 -3.428e-04 2.051e-04 -1.671 0.094687 .
## stat55 2.826e-04 2.014e-04 1.403 0.160705
## stat56 6.002e-05 2.046e-04 0.293 0.769318
## stat57 1.627e-04 2.017e-04 0.807 0.419743
## stat58 -2.826e-05 2.015e-04 -0.140 0.888500
## stat59 2.567e-04 2.037e-04 1.260 0.207692
## stat60 3.690e-04 2.034e-04 1.814 0.069711 .
## stat61 1.570e-04 2.048e-04 0.766 0.443492
## stat62 -2.185e-04 2.036e-04 -1.073 0.283221
## stat63 1.596e-04 2.032e-04 0.785 0.432356
## stat64 1.773e-04 2.023e-04 0.876 0.380918
## stat65 -7.033e-05 2.041e-04 -0.345 0.730397
## stat66 1.646e-04 2.058e-04 0.800 0.423645
## stat67 1.985e-04 2.054e-04 0.966 0.334036
## stat68 -8.308e-05 2.039e-04 -0.407 0.683727
## stat69 -6.792e-05 2.042e-04 -0.333 0.739494
## stat70 2.981e-04 2.029e-04 1.469 0.141890
## stat71 4.023e-04 2.031e-04 1.981 0.047650 *
## stat72 5.627e-05 2.047e-04 0.275 0.783351
## stat73 5.067e-04 2.059e-04 2.461 0.013874 *
## stat74 3.584e-05 2.035e-04 0.176 0.860174
## stat75 1.745e-04 2.051e-04 0.851 0.394876
## stat76 1.582e-04 2.046e-04 0.773 0.439295
## stat77 5.558e-05 2.037e-04 0.273 0.784963
## stat78 -2.849e-04 2.031e-04 -1.403 0.160760
## stat79 -1.309e-04 2.036e-04 -0.643 0.520315
## stat80 2.775e-04 2.051e-04 1.353 0.176180
## stat81 2.787e-04 2.041e-04 1.365 0.172278
## stat82 2.071e-04 2.035e-04 1.018 0.308802
## stat83 -1.752e-05 2.040e-04 -0.086 0.931567
## stat84 -7.968e-05 2.038e-04 -0.391 0.695827
## stat85 -5.549e-05 2.030e-04 -0.273 0.784561
## stat86 3.300e-04 2.044e-04 1.615 0.106424
## stat87 -4.055e-04 2.047e-04 -1.981 0.047646 *
## stat88 7.719e-05 2.013e-04 0.383 0.701386
## stat89 2.055e-06 2.035e-04 0.010 0.991942
## stat90 -2.298e-04 2.051e-04 -1.121 0.262525
## stat91 -4.032e-04 2.031e-04 -1.985 0.047157 *
## stat92 -2.096e-04 2.040e-04 -1.028 0.304189
## stat93 -9.446e-05 2.074e-04 -0.455 0.648821
## stat94 7.290e-05 2.028e-04 0.359 0.719294
## stat95 1.153e-04 2.028e-04 0.568 0.569807
## stat96 -2.239e-04 2.037e-04 -1.099 0.271678
## stat97 1.540e-04 2.024e-04 0.761 0.446711
## stat98 3.444e-03 2.008e-04 17.151 < 2e-16 ***
## stat99 3.586e-04 2.048e-04 1.751 0.080033 .
## stat100 3.331e-04 2.045e-04 1.629 0.103403
## stat101 -1.527e-05 2.048e-04 -0.075 0.940558
## stat102 1.059e-04 2.043e-04 0.519 0.604100
## stat103 -2.891e-04 2.059e-04 -1.404 0.160366
## stat104 -2.192e-04 2.042e-04 -1.074 0.283096
## stat105 5.882e-05 2.018e-04 0.292 0.770674
## stat106 -3.807e-04 2.029e-04 -1.876 0.060668 .
## stat107 1.804e-05 2.021e-04 0.089 0.928873
## stat108 -3.151e-05 2.045e-04 -0.154 0.877548
## stat109 -1.450e-04 2.026e-04 -0.715 0.474367
## stat110 -3.135e-03 2.030e-04 -15.439 < 2e-16 ***
## stat111 -2.426e-04 2.030e-04 -1.195 0.232205
## stat112 -2.078e-04 2.045e-04 -1.016 0.309442
## stat113 8.077e-06 2.041e-04 0.040 0.968436
## stat114 1.651e-04 2.039e-04 0.810 0.418068
## stat115 4.326e-04 2.024e-04 2.137 0.032625 *
## stat116 2.919e-04 2.033e-04 1.436 0.151069
## stat117 1.205e-04 2.049e-04 0.588 0.556455
## stat118 9.342e-06 2.017e-04 0.046 0.963058
## stat119 1.084e-04 2.029e-04 0.534 0.593277
## stat120 4.662e-05 2.018e-04 0.231 0.817298
## stat121 -1.812e-04 2.038e-04 -0.889 0.374009
## stat122 -2.987e-04 2.025e-04 -1.475 0.140325
## stat123 1.359e-05 2.056e-04 0.066 0.947285
## stat124 -2.422e-04 2.040e-04 -1.187 0.235206
## stat125 1.931e-04 2.037e-04 0.948 0.343184
## stat126 1.178e-04 2.032e-04 0.580 0.562149
## stat127 1.050e-04 2.033e-04 0.517 0.605391
## stat128 5.778e-06 2.024e-04 0.029 0.977224
## stat129 3.888e-05 2.023e-04 0.192 0.847639
## stat130 8.411e-05 2.030e-04 0.414 0.678591
## stat131 8.275e-05 2.043e-04 0.405 0.685529
## stat132 -1.710e-04 2.011e-04 -0.850 0.395195
## stat133 4.090e-04 2.039e-04 2.006 0.044901 *
## stat134 -1.846e-04 2.037e-04 -0.906 0.364778
## stat135 -2.380e-04 2.043e-04 -1.165 0.244197
## stat136 -1.823e-04 2.047e-04 -0.890 0.373282
## stat137 1.160e-04 2.010e-04 0.577 0.563809
## stat138 -6.555e-05 2.040e-04 -0.321 0.747925
## stat139 -7.649e-06 2.045e-04 -0.037 0.970162
## stat140 1.587e-04 2.018e-04 0.787 0.431578
## stat141 2.354e-04 2.029e-04 1.160 0.246021
## stat142 5.978e-05 2.049e-04 0.292 0.770473
## stat143 -1.507e-04 2.040e-04 -0.739 0.459889
## stat144 2.282e-04 2.028e-04 1.126 0.260361
## stat145 -1.627e-05 2.056e-04 -0.079 0.936917
## stat146 -6.365e-04 2.052e-04 -3.102 0.001936 **
## stat147 -2.574e-04 2.051e-04 -1.255 0.209494
## stat148 -3.111e-04 2.020e-04 -1.540 0.123600
## stat149 -6.283e-04 2.049e-04 -3.067 0.002174 **
## stat150 -3.922e-05 2.059e-04 -0.190 0.848960
## stat151 5.189e-04 2.049e-04 2.532 0.011365 *
## stat152 -1.232e-04 2.016e-04 -0.611 0.541108
## stat153 3.557e-04 2.064e-04 1.723 0.084963 .
## stat154 1.474e-04 2.060e-04 0.716 0.474230
## stat155 1.481e-04 2.024e-04 0.732 0.464181
## stat156 1.878e-04 2.058e-04 0.912 0.361703
## stat157 -7.195e-06 2.032e-04 -0.035 0.971752
## stat158 1.497e-04 2.054e-04 0.729 0.466216
## stat159 9.139e-05 2.027e-04 0.451 0.652086
## stat160 -3.256e-05 2.053e-04 -0.159 0.873974
## stat161 3.144e-04 2.041e-04 1.541 0.123473
## stat162 5.708e-05 2.015e-04 0.283 0.777005
## stat163 2.560e-04 2.063e-04 1.241 0.214666
## stat164 1.136e-04 2.058e-04 0.552 0.581095
## stat165 -4.807e-05 2.026e-04 -0.237 0.812460
## stat166 -1.726e-04 2.012e-04 -0.858 0.390961
## stat167 -5.178e-04 2.041e-04 -2.537 0.011209 *
## stat168 -2.068e-04 2.024e-04 -1.022 0.306887
## stat169 1.074e-06 2.035e-04 0.005 0.995789
## stat170 -1.562e-04 2.038e-04 -0.766 0.443623
## stat171 -2.270e-04 2.054e-04 -1.105 0.269219
## stat172 5.966e-04 2.007e-04 2.972 0.002974 **
## stat173 -7.250e-05 2.050e-04 -0.354 0.723549
## stat174 2.123e-04 2.039e-04 1.042 0.297641
## stat175 -3.867e-04 2.032e-04 -1.903 0.057041 .
## stat176 4.736e-05 2.036e-04 0.233 0.816074
## stat177 -3.796e-04 2.039e-04 -1.861 0.062741 .
## stat178 -1.706e-05 2.061e-04 -0.083 0.934019
## stat179 -6.416e-05 2.023e-04 -0.317 0.751161
## stat180 -1.692e-04 2.030e-04 -0.834 0.404486
## stat181 4.094e-04 2.041e-04 2.006 0.044952 *
## stat182 2.190e-04 2.047e-04 1.070 0.284685
## stat183 2.256e-04 2.030e-04 1.112 0.266388
## stat184 3.365e-04 2.044e-04 1.646 0.099795 .
## stat185 -2.896e-05 2.013e-04 -0.144 0.885581
## stat186 1.511e-04 2.053e-04 0.736 0.461882
## stat187 -1.727e-04 2.032e-04 -0.850 0.395461
## stat188 2.991e-04 2.035e-04 1.470 0.141742
## stat189 -6.504e-05 2.057e-04 -0.316 0.751902
## stat190 -1.081e-04 2.026e-04 -0.533 0.593752
## stat191 -2.952e-04 2.042e-04 -1.446 0.148312
## stat192 5.473e-05 2.069e-04 0.264 0.791434
## stat193 1.205e-04 2.059e-04 0.585 0.558281
## stat194 -5.902e-06 2.032e-04 -0.029 0.976824
## stat195 3.088e-04 2.037e-04 1.516 0.129609
## stat196 -3.806e-04 2.062e-04 -1.846 0.064992 .
## stat197 -2.438e-04 2.010e-04 -1.213 0.225335
## stat198 -1.766e-04 2.051e-04 -0.861 0.389140
## stat199 1.977e-04 2.021e-04 0.979 0.327864
## stat200 -2.513e-04 2.025e-04 -1.241 0.214686
## stat201 7.178e-05 2.026e-04 0.354 0.723093
## stat202 5.806e-06 2.064e-04 0.028 0.977560
## stat203 -8.281e-05 2.030e-04 -0.408 0.683406
## stat204 -1.970e-04 2.028e-04 -0.971 0.331552
## stat205 1.459e-04 2.017e-04 0.723 0.469469
## stat206 -1.575e-04 2.045e-04 -0.770 0.441276
## stat207 4.263e-04 2.037e-04 2.093 0.036400 *
## stat208 7.375e-05 2.044e-04 0.361 0.718265
## stat209 5.482e-05 2.026e-04 0.271 0.786753
## stat210 -4.652e-04 2.050e-04 -2.269 0.023318 *
## stat211 -1.620e-04 2.046e-04 -0.792 0.428394
## stat212 -3.511e-05 2.043e-04 -0.172 0.863578
## stat213 -2.529e-04 2.043e-04 -1.238 0.215662
## stat214 -9.808e-05 2.044e-04 -0.480 0.631401
## stat215 -2.294e-04 2.044e-04 -1.122 0.261828
## stat216 -1.732e-05 2.041e-04 -0.085 0.932373
## stat217 1.871e-05 2.036e-04 0.092 0.926776
## x18.sqrt 2.643e-02 7.718e-04 34.246 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02507 on 5053 degrees of freedom
## Multiple R-squared: 0.3722, Adjusted R-squared: 0.3424
## F-statistic: 12.48 on 240 and 5053 DF, p-value: < 2.2e-16
cd.full2 = plot.diagnostics(model.full2, data.train2)
## [1] "Number of data points that have Cook's D > 4/n: 267"
## [1] "Number of data points that have Cook's D > 1: 0"
# much more normal residuals than before.
# Checking to see if distributions are different and if so whcih variables
# High Leverage Plot
plotData = data.train %>%
rownames_to_column() %>%
mutate(type=ifelse(rowname %in% high.cd,'High','Normal')) %>%
dplyr::select(type,target=one_of(label.names))
ggplot(data=plotData, aes(x=type,y=target)) +
geom_boxplot(fill='light blue',outlier.shape=NA) +
scale_y_continuous(name="Target Variable Values",label=scales::comma_format(accuracy=.1)) +
theme_light() +
ggtitle('Distribution of High Leverage Points and Normal Points')
# 2 sample t-tests
plotData = data.train %>%
rownames_to_column() %>%
mutate(type=ifelse(rowname %in% high.cd,'High','Normal')) %>%
dplyr::select(type,one_of(feature.names))
comp.test = lapply(dplyr::select(plotData, one_of(feature.names))
, function(x) t.test(x ~ plotData$type, var.equal = TRUE))
sig.comp = list.filter(comp.test, p.value < 0.05)
sapply(sig.comp, function(x) x[['p.value']])
## x4 x14 stat19 stat74 stat82 stat85 stat95 stat98 stat104
## 3.214527e-02 5.054211e-03 2.408416e-02 4.509752e-02 2.882358e-02 4.109183e-02 4.855706e-02 1.787789e-05 1.721049e-02
## stat110 stat128 stat151 x18.sqrt
## 5.093098e-04 1.412447e-03 1.000603e-02 4.295876e-02
mm = melt(plotData, id=c('type')) %>% filter(variable %in% names(sig.comp))
ggplot(mm,aes(x=type, y=value)) +
geom_boxplot()+
facet_wrap(~variable, ncol=5, scales = 'free_y') +
scale_y_continuous(name="values",label=scales::comma_format(accuracy=.1)) +
ggtitle('Distribution of High Leverage Points and Normal Points')
# Distribution (box) Plots
mm = melt(plotData, id=c('type'))
ggplot(mm,aes(x=type, y=value)) +
geom_boxplot()+
facet_wrap(~variable, ncol=8, scales = 'free_y') +
scale_y_continuous(name="values",label=scales::comma_format(accuracy=.1)) +
ggtitle('Distribution of High Leverage Points and Normal Points')
model.null = lm(grand.mean.formula, data.train)
summary(model.null)
##
## Call:
## lm(formula = grand.mean.formula, data = data.train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.110120 -0.023942 -0.003226 0.020591 0.190160
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.0970286 0.0004831 4341 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0361 on 5583 degrees of freedom
Basic: http://www.stat.columbia.edu/~martin/W2024/R10.pdf Cross Validation + Other Metrics: http://www.sthda.com/english/articles/37-model-selection-essentials-in-r/154-stepwise-regression-essentials-in-r/
if (algo.forward.caret == TRUE){
set.seed(1)
returned = train.caret.glmselect(formula = formula
, data = data.train
, method = "leapForward"
, feature.names = feature.names)
model.forward = returned$model
id = returned$id
}
## Aggregating results
## Selecting tuning parameters
## Fitting nvmax = 15 on full training set
## [1] "All models results"
## nvmax RMSE Rsquared MAE RMSESD RsquaredSD MAESD
## 1 1 0.03401434 0.1129284 0.02643588 0.001653505 0.02622841 0.001102860
## 2 2 0.03327509 0.1508562 0.02584895 0.001824017 0.02882595 0.001298308
## 3 3 0.03268776 0.1806362 0.02522895 0.001724857 0.02926289 0.001242842
## 4 4 0.03221824 0.2037167 0.02457710 0.001619741 0.02635159 0.001155205
## 5 5 0.03198566 0.2150295 0.02440800 0.001623696 0.02619591 0.001159999
## 6 6 0.03196348 0.2163788 0.02441940 0.001696140 0.02841727 0.001174286
## 7 7 0.03180550 0.2239996 0.02428267 0.001715946 0.03089328 0.001199637
## 8 8 0.03174826 0.2265913 0.02425835 0.001683503 0.02873522 0.001171472
## 9 9 0.03178904 0.2246853 0.02428039 0.001704478 0.02955390 0.001170683
## 10 10 0.03177374 0.2253224 0.02427874 0.001691829 0.02774504 0.001128675
## 11 11 0.03177040 0.2255159 0.02427981 0.001670797 0.02729749 0.001123762
## 12 12 0.03176208 0.2259251 0.02429125 0.001680949 0.02809431 0.001134895
## 13 13 0.03175935 0.2260897 0.02428991 0.001688991 0.02737024 0.001145900
## 14 14 0.03174727 0.2267631 0.02428874 0.001676773 0.02679936 0.001130957
## 15 15 0.03172887 0.2277161 0.02427692 0.001696985 0.02798228 0.001150043
## 16 16 0.03175348 0.2266272 0.02428481 0.001702021 0.02818457 0.001145718
## 17 17 0.03176076 0.2262748 0.02429676 0.001698544 0.02817721 0.001120934
## 18 18 0.03175098 0.2266904 0.02429000 0.001663323 0.02767559 0.001091910
## 19 19 0.03176832 0.2258468 0.02430214 0.001642422 0.02596093 0.001078176
## 20 20 0.03177849 0.2253463 0.02431685 0.001646734 0.02577676 0.001074751
## 21 21 0.03179040 0.2247855 0.02433509 0.001665307 0.02577533 0.001096565
## 22 22 0.03180574 0.2241727 0.02434164 0.001696696 0.02671741 0.001130238
## 23 23 0.03181246 0.2239205 0.02434062 0.001684177 0.02648960 0.001114691
## 24 24 0.03184254 0.2224925 0.02435997 0.001669421 0.02551720 0.001111649
## 25 25 0.03187265 0.2211139 0.02437518 0.001667392 0.02587778 0.001115902
## 26 26 0.03187155 0.2211404 0.02436642 0.001645837 0.02529189 0.001099753
## 27 27 0.03189182 0.2202059 0.02438159 0.001635787 0.02533427 0.001083287
## 28 28 0.03189392 0.2200564 0.02439148 0.001631473 0.02424075 0.001084623
## 29 29 0.03190829 0.2194066 0.02440219 0.001623528 0.02359936 0.001085814
## 30 30 0.03190906 0.2194141 0.02439971 0.001620326 0.02389469 0.001089350
## 31 31 0.03192524 0.2187288 0.02440835 0.001647820 0.02421457 0.001108163
## 32 32 0.03195286 0.2174882 0.02442233 0.001649999 0.02405021 0.001118571
## 33 33 0.03195589 0.2173721 0.02442780 0.001648991 0.02374708 0.001114576
## 34 34 0.03197439 0.2165185 0.02443763 0.001641506 0.02348014 0.001101318
## 35 35 0.03199278 0.2157339 0.02445629 0.001655695 0.02378244 0.001130864
## 36 36 0.03200683 0.2151304 0.02447338 0.001661775 0.02421777 0.001133489
## 37 37 0.03201513 0.2147362 0.02448818 0.001672260 0.02452034 0.001138308
## 38 38 0.03202230 0.2145026 0.02449059 0.001669245 0.02509166 0.001137510
## 39 39 0.03203206 0.2140852 0.02449147 0.001677827 0.02523732 0.001147686
## 40 40 0.03204346 0.2136493 0.02449324 0.001681521 0.02603516 0.001141767
## 41 41 0.03205085 0.2133617 0.02450001 0.001692290 0.02714892 0.001159606
## 42 42 0.03207073 0.2124059 0.02451474 0.001669286 0.02637865 0.001130998
## 43 43 0.03208226 0.2118732 0.02452223 0.001664949 0.02609890 0.001126058
## 44 44 0.03208231 0.2118823 0.02453043 0.001659426 0.02580084 0.001118972
## 45 45 0.03209240 0.2114628 0.02453707 0.001653321 0.02545142 0.001128189
## 46 46 0.03211006 0.2107579 0.02454934 0.001663280 0.02608438 0.001133514
## 47 47 0.03210769 0.2108776 0.02455096 0.001668545 0.02605674 0.001141764
## 48 48 0.03211250 0.2106471 0.02456103 0.001663891 0.02587145 0.001144169
## 49 49 0.03213425 0.2097320 0.02457200 0.001683324 0.02666777 0.001161543
## 50 50 0.03214649 0.2092133 0.02458028 0.001680040 0.02621740 0.001150749
## 51 51 0.03215526 0.2088147 0.02458861 0.001680527 0.02635129 0.001155930
## 52 52 0.03217676 0.2078489 0.02460212 0.001682038 0.02587413 0.001161405
## 53 53 0.03218581 0.2074595 0.02460006 0.001681702 0.02548463 0.001160304
## 54 54 0.03219310 0.2071739 0.02460504 0.001682787 0.02555196 0.001168606
## 55 55 0.03218659 0.2074539 0.02461139 0.001674118 0.02466636 0.001155782
## 56 56 0.03219598 0.2070534 0.02462114 0.001660430 0.02434823 0.001140367
## 57 57 0.03219792 0.2070722 0.02462455 0.001673246 0.02500550 0.001163207
## 58 58 0.03220144 0.2069599 0.02462907 0.001673877 0.02495455 0.001170212
## 59 59 0.03220591 0.2068000 0.02463360 0.001676646 0.02491548 0.001168885
## 60 60 0.03220813 0.2067446 0.02463610 0.001673852 0.02490250 0.001159862
## 61 61 0.03222292 0.2060673 0.02465219 0.001664338 0.02435540 0.001155105
## 62 62 0.03222767 0.2058399 0.02466000 0.001655426 0.02365070 0.001153655
## 63 63 0.03223556 0.2055054 0.02466303 0.001660236 0.02340372 0.001147581
## 64 64 0.03224491 0.2051429 0.02466891 0.001669971 0.02371415 0.001158506
## 65 65 0.03225492 0.2047863 0.02468146 0.001675832 0.02394880 0.001152333
## 66 66 0.03225498 0.2048359 0.02468825 0.001682988 0.02411791 0.001156261
## 67 67 0.03226554 0.2043747 0.02469430 0.001677683 0.02419212 0.001166505
## 68 68 0.03226692 0.2043190 0.02469249 0.001661691 0.02366215 0.001152238
## 69 69 0.03227643 0.2039052 0.02469393 0.001651805 0.02338413 0.001145464
## 70 70 0.03227957 0.2037809 0.02469925 0.001638465 0.02304676 0.001137143
## 71 71 0.03227967 0.2037973 0.02470733 0.001646022 0.02323760 0.001150509
## 72 72 0.03227908 0.2038626 0.02470341 0.001632021 0.02308002 0.001138321
## 73 73 0.03228944 0.2034463 0.02471639 0.001630117 0.02321283 0.001135186
## 74 74 0.03229335 0.2033067 0.02472347 0.001623739 0.02305410 0.001129480
## 75 75 0.03228187 0.2038272 0.02471619 0.001625284 0.02348794 0.001129362
## 76 76 0.03228328 0.2037638 0.02471149 0.001624905 0.02349492 0.001126076
## 77 77 0.03229132 0.2034105 0.02472241 0.001622842 0.02321086 0.001123532
## 78 78 0.03229478 0.2032605 0.02472742 0.001613670 0.02272783 0.001114460
## 79 79 0.03229827 0.2031661 0.02473087 0.001618020 0.02276677 0.001123253
## 80 80 0.03229709 0.2032287 0.02472834 0.001632435 0.02295500 0.001130835
## 81 81 0.03228901 0.2036295 0.02471555 0.001643756 0.02336513 0.001143256
## 82 82 0.03229158 0.2035232 0.02471719 0.001638786 0.02326427 0.001137341
## 83 83 0.03229553 0.2033728 0.02472424 0.001640087 0.02330925 0.001137305
## 84 84 0.03229793 0.2032998 0.02473123 0.001628762 0.02298312 0.001119967
## 85 85 0.03229184 0.2035809 0.02472851 0.001628230 0.02294010 0.001119420
## 86 86 0.03229300 0.2035074 0.02473404 0.001634289 0.02305930 0.001117857
## 87 87 0.03228434 0.2039288 0.02473388 0.001632344 0.02333182 0.001116825
## 88 88 0.03228655 0.2038642 0.02474361 0.001626836 0.02342706 0.001105295
## 89 89 0.03228557 0.2039507 0.02473778 0.001636407 0.02373020 0.001106525
## 90 90 0.03228738 0.2039307 0.02474077 0.001643941 0.02408071 0.001112028
## 91 91 0.03228316 0.2041063 0.02473683 0.001646528 0.02418941 0.001108441
## 92 92 0.03228212 0.2041860 0.02472933 0.001649809 0.02416266 0.001113497
## 93 93 0.03228486 0.2040377 0.02472851 0.001640761 0.02397177 0.001110423
## 94 94 0.03227691 0.2043567 0.02472280 0.001635127 0.02355182 0.001107387
## 95 95 0.03227107 0.2046603 0.02472070 0.001633994 0.02369396 0.001106422
## 96 96 0.03226481 0.2049236 0.02471866 0.001627654 0.02344351 0.001100760
## 97 97 0.03226430 0.2049334 0.02471618 0.001635280 0.02346000 0.001107411
## 98 98 0.03226858 0.2047882 0.02471794 0.001629267 0.02346004 0.001104331
## 99 99 0.03227098 0.2046998 0.02472570 0.001639804 0.02374235 0.001115105
## 100 100 0.03226930 0.2047961 0.02472135 0.001638878 0.02390839 0.001116364
## 101 101 0.03227663 0.2045012 0.02472888 0.001641557 0.02404260 0.001112623
## 102 102 0.03227884 0.2044044 0.02472634 0.001638453 0.02385893 0.001110982
## 103 103 0.03227475 0.2045764 0.02472228 0.001636290 0.02378804 0.001108926
## 104 104 0.03227643 0.2044879 0.02473140 0.001635838 0.02364720 0.001110691
## 105 105 0.03228026 0.2043649 0.02473372 0.001633256 0.02364724 0.001105222
## 106 106 0.03227539 0.2045635 0.02473092 0.001636249 0.02371933 0.001104631
## 107 107 0.03228100 0.2043385 0.02473354 0.001635577 0.02354128 0.001103316
## 108 108 0.03229050 0.2039286 0.02474116 0.001632681 0.02322061 0.001099374
## 109 109 0.03229011 0.2039746 0.02473931 0.001628404 0.02322996 0.001093708
## 110 110 0.03228816 0.2040929 0.02473948 0.001636902 0.02340012 0.001101536
## 111 111 0.03228836 0.2040993 0.02473904 0.001631891 0.02357594 0.001095355
## 112 112 0.03229559 0.2038394 0.02474369 0.001635245 0.02384828 0.001099985
## 113 113 0.03229833 0.2037090 0.02474051 0.001631859 0.02384474 0.001094300
## 114 114 0.03230162 0.2035949 0.02473776 0.001621450 0.02359713 0.001082806
## 115 115 0.03230573 0.2034476 0.02474026 0.001626847 0.02393211 0.001080925
## 116 116 0.03230713 0.2033694 0.02474770 0.001624742 0.02396315 0.001075360
## 117 117 0.03230807 0.2033355 0.02474802 0.001630191 0.02406837 0.001074631
## 118 118 0.03230444 0.2035191 0.02474406 0.001629888 0.02432294 0.001074001
## 119 119 0.03231320 0.2032017 0.02474935 0.001640501 0.02473969 0.001078833
## 120 120 0.03230996 0.2033900 0.02474709 0.001641913 0.02504147 0.001077418
## 121 121 0.03231973 0.2029855 0.02475445 0.001643981 0.02497313 0.001081821
## 122 122 0.03232432 0.2028347 0.02475880 0.001640663 0.02523495 0.001077560
## 123 123 0.03232930 0.2026314 0.02476073 0.001641932 0.02507160 0.001078507
## 124 124 0.03232735 0.2027433 0.02475956 0.001649821 0.02546182 0.001088728
## 125 125 0.03232254 0.2029622 0.02475360 0.001651667 0.02539643 0.001093458
## 126 126 0.03232071 0.2030147 0.02475410 0.001649515 0.02522372 0.001090516
## 127 127 0.03232101 0.2030096 0.02475554 0.001652276 0.02518284 0.001095574
## 128 128 0.03232317 0.2029113 0.02475302 0.001648595 0.02523705 0.001095774
## 129 129 0.03232896 0.2026593 0.02475790 0.001649681 0.02518309 0.001097156
## 130 130 0.03233358 0.2024760 0.02476135 0.001647466 0.02534552 0.001095855
## 131 131 0.03233254 0.2025305 0.02476169 0.001650565 0.02553175 0.001093565
## 132 132 0.03233885 0.2022919 0.02476865 0.001661449 0.02586656 0.001098060
## 133 133 0.03234491 0.2020258 0.02477580 0.001664287 0.02589046 0.001098180
## 134 134 0.03234423 0.2020624 0.02477772 0.001667769 0.02597946 0.001103350
## 135 135 0.03234473 0.2020683 0.02477619 0.001670277 0.02611383 0.001106414
## 136 136 0.03235153 0.2017780 0.02477780 0.001667447 0.02597319 0.001108515
## 137 137 0.03235639 0.2015845 0.02478448 0.001665622 0.02613582 0.001106683
## 138 138 0.03235862 0.2014396 0.02478412 0.001663134 0.02604193 0.001104814
## 139 139 0.03235811 0.2014849 0.02478245 0.001666543 0.02600681 0.001110470
## 140 140 0.03236702 0.2011368 0.02478851 0.001676213 0.02635925 0.001118152
## 141 141 0.03236105 0.2014138 0.02478649 0.001673168 0.02627377 0.001109516
## 142 142 0.03236397 0.2012786 0.02478803 0.001667676 0.02617907 0.001105283
## 143 143 0.03236791 0.2011325 0.02478819 0.001671795 0.02642341 0.001102823
## 144 144 0.03237109 0.2009932 0.02478963 0.001669254 0.02632074 0.001098096
## 145 145 0.03237643 0.2007925 0.02479571 0.001665958 0.02630796 0.001098020
## 146 146 0.03237937 0.2006567 0.02480001 0.001663721 0.02600367 0.001096395
## 147 147 0.03238099 0.2006043 0.02480267 0.001665837 0.02609317 0.001101126
## 148 148 0.03238192 0.2005614 0.02480245 0.001666302 0.02622458 0.001098030
## 149 149 0.03237481 0.2008736 0.02479483 0.001666696 0.02645876 0.001099589
## 150 150 0.03237687 0.2008141 0.02479366 0.001671502 0.02642736 0.001110929
## 151 151 0.03237717 0.2007924 0.02479301 0.001668665 0.02641475 0.001110854
## 152 152 0.03237958 0.2007005 0.02479210 0.001670624 0.02662172 0.001108732
## 153 153 0.03238480 0.2004765 0.02479141 0.001669496 0.02667451 0.001108025
## 154 154 0.03238247 0.2005708 0.02478914 0.001667053 0.02655197 0.001106688
## 155 155 0.03238225 0.2005550 0.02478876 0.001665707 0.02659397 0.001106720
## 156 156 0.03238590 0.2004028 0.02479090 0.001663578 0.02657060 0.001104736
## 157 157 0.03238865 0.2002951 0.02479175 0.001662997 0.02646314 0.001105166
## 158 158 0.03238857 0.2002859 0.02479276 0.001658915 0.02612871 0.001103988
## 159 159 0.03239084 0.2001907 0.02479319 0.001658355 0.02612926 0.001104620
## 160 160 0.03239370 0.2000498 0.02479787 0.001654850 0.02590117 0.001105683
## 161 161 0.03239563 0.1999668 0.02479654 0.001659532 0.02595596 0.001109830
## 162 162 0.03240018 0.1997895 0.02479983 0.001658858 0.02609660 0.001110604
## 163 163 0.03240150 0.1997270 0.02480001 0.001660366 0.02624344 0.001107684
## 164 164 0.03240078 0.1997435 0.02480118 0.001655470 0.02604631 0.001104099
## 165 165 0.03239939 0.1998052 0.02479912 0.001655268 0.02611400 0.001104404
## 166 166 0.03239754 0.1998871 0.02479658 0.001655986 0.02609984 0.001104199
## 167 167 0.03240249 0.1996837 0.02480095 0.001659110 0.02620574 0.001106321
## 168 168 0.03240225 0.1997149 0.02479799 0.001661027 0.02616434 0.001106871
## 169 169 0.03240179 0.1997339 0.02479814 0.001660472 0.02624381 0.001107598
## 170 170 0.03240325 0.1996637 0.02479709 0.001662785 0.02618527 0.001111457
## 171 171 0.03240793 0.1994512 0.02480402 0.001659265 0.02596125 0.001109351
## 172 172 0.03240762 0.1994526 0.02480571 0.001659721 0.02604514 0.001111101
## 173 173 0.03241113 0.1992921 0.02480763 0.001661179 0.02601223 0.001112833
## 174 174 0.03241227 0.1992520 0.02480830 0.001663868 0.02603946 0.001116353
## 175 175 0.03241220 0.1992558 0.02481049 0.001663838 0.02595215 0.001115646
## 176 176 0.03241338 0.1992239 0.02481234 0.001668821 0.02607627 0.001117117
## 177 177 0.03241017 0.1993653 0.02481099 0.001667773 0.02608223 0.001115467
## 178 178 0.03241202 0.1992881 0.02481172 0.001672370 0.02627175 0.001118791
## 179 179 0.03241058 0.1993441 0.02481165 0.001670766 0.02616852 0.001116763
## 180 180 0.03241188 0.1992898 0.02481396 0.001669766 0.02619970 0.001114728
## 181 181 0.03241034 0.1993630 0.02481312 0.001666667 0.02607655 0.001111640
## 182 182 0.03241082 0.1993468 0.02481432 0.001667849 0.02598220 0.001112291
## 183 183 0.03241393 0.1992147 0.02481903 0.001666766 0.02592809 0.001112001
## 184 184 0.03241455 0.1991912 0.02481847 0.001667572 0.02593656 0.001112064
## 185 185 0.03241462 0.1991889 0.02481949 0.001666271 0.02586464 0.001111589
## 186 186 0.03241349 0.1992501 0.02481902 0.001669630 0.02591570 0.001114797
## 187 187 0.03241502 0.1991848 0.02481999 0.001667480 0.02583440 0.001112875
## 188 188 0.03241539 0.1991843 0.02482031 0.001669370 0.02589930 0.001116246
## 189 189 0.03241651 0.1991240 0.02482286 0.001669014 0.02597125 0.001115719
## 190 190 0.03241553 0.1991680 0.02482158 0.001668987 0.02598034 0.001115467
## 191 191 0.03241510 0.1991787 0.02482076 0.001667437 0.02594801 0.001114204
## 192 192 0.03241354 0.1992337 0.02482043 0.001665558 0.02592572 0.001112933
## 193 193 0.03241245 0.1992831 0.02481851 0.001667168 0.02600805 0.001115311
## 194 194 0.03241303 0.1992514 0.02481974 0.001666355 0.02590066 0.001115345
## 195 195 0.03241282 0.1992572 0.02482012 0.001667109 0.02598829 0.001115275
## 196 196 0.03241244 0.1992656 0.02482171 0.001666193 0.02594014 0.001114951
## 197 197 0.03241476 0.1991624 0.02482265 0.001665120 0.02582746 0.001115282
## 198 198 0.03241511 0.1991380 0.02482287 0.001663673 0.02573424 0.001114116
## 199 199 0.03241836 0.1989957 0.02482431 0.001663674 0.02570291 0.001114462
## 200 200 0.03242098 0.1988907 0.02482624 0.001665925 0.02573230 0.001115361
## 201 201 0.03242121 0.1988873 0.02482590 0.001665849 0.02575072 0.001115177
## 202 202 0.03242019 0.1989232 0.02482727 0.001665922 0.02569997 0.001115749
## 203 203 0.03242171 0.1988500 0.02482869 0.001665853 0.02570676 0.001115684
## 204 204 0.03242247 0.1988211 0.02482887 0.001666421 0.02570974 0.001117567
## 205 205 0.03242220 0.1988275 0.02482759 0.001664984 0.02569562 0.001116582
## 206 206 0.03242274 0.1987923 0.02482911 0.001663824 0.02562022 0.001116856
## 207 207 0.03242159 0.1988437 0.02482838 0.001663210 0.02562531 0.001117348
## 208 208 0.03242107 0.1988813 0.02482874 0.001662465 0.02566752 0.001118128
## 209 209 0.03242083 0.1988934 0.02482822 0.001662334 0.02565781 0.001118060
## 210 210 0.03242108 0.1988920 0.02482744 0.001663677 0.02576120 0.001117863
## 211 211 0.03242127 0.1988851 0.02482792 0.001664835 0.02580157 0.001118328
## 212 212 0.03241903 0.1989840 0.02482523 0.001663797 0.02582182 0.001116644
## 213 213 0.03241880 0.1989980 0.02482547 0.001663820 0.02577922 0.001117195
## 214 214 0.03241798 0.1990293 0.02482471 0.001662374 0.02573303 0.001116862
## 215 215 0.03241820 0.1990202 0.02482473 0.001662506 0.02575708 0.001117873
## 216 216 0.03241661 0.1990887 0.02482411 0.001661291 0.02570533 0.001118090
## 217 217 0.03241672 0.1990814 0.02482366 0.001661302 0.02571403 0.001118959
## 218 218 0.03241534 0.1991370 0.02482213 0.001661462 0.02570781 0.001119755
## 219 219 0.03241515 0.1991480 0.02482193 0.001662119 0.02569389 0.001119940
## 220 220 0.03241499 0.1991551 0.02482232 0.001662201 0.02569115 0.001120470
## 221 221 0.03241610 0.1991075 0.02482339 0.001662241 0.02566495 0.001119904
## 222 222 0.03241602 0.1991074 0.02482417 0.001661300 0.02564632 0.001119425
## 223 223 0.03241672 0.1990779 0.02482533 0.001661313 0.02563612 0.001118930
## 224 224 0.03241663 0.1990794 0.02482563 0.001661300 0.02564137 0.001118505
## 225 225 0.03241777 0.1990315 0.02482636 0.001661908 0.02565946 0.001119507
## 226 226 0.03241783 0.1990293 0.02482596 0.001661740 0.02567120 0.001119412
## 227 227 0.03241807 0.1990222 0.02482588 0.001662327 0.02568653 0.001119877
## 228 228 0.03241771 0.1990394 0.02482622 0.001662357 0.02571741 0.001120231
## 229 229 0.03241783 0.1990376 0.02482649 0.001662633 0.02575663 0.001120400
## 230 230 0.03241756 0.1990477 0.02482596 0.001663162 0.02578357 0.001120430
## 231 231 0.03241816 0.1990219 0.02482649 0.001663076 0.02576580 0.001120536
## 232 232 0.03241806 0.1990258 0.02482641 0.001663205 0.02577734 0.001120702
## 233 233 0.03241819 0.1990201 0.02482649 0.001662966 0.02578684 0.001120359
## 234 234 0.03241791 0.1990320 0.02482610 0.001663157 0.02579253 0.001120550
## 235 235 0.03241782 0.1990370 0.02482623 0.001662943 0.02578869 0.001120480
## 236 236 0.03241774 0.1990414 0.02482617 0.001663055 0.02579726 0.001120485
## 237 237 0.03241764 0.1990444 0.02482617 0.001663121 0.02579756 0.001120597
## 238 238 0.03241757 0.1990470 0.02482614 0.001663087 0.02579691 0.001120563
## 239 239 0.03241743 0.1990526 0.02482609 0.001662957 0.02579164 0.001120500
## 240 240 0.03241747 0.1990510 0.02482615 0.001663024 0.02579431 0.001120562
## [1] "Best Model"
## nvmax
## 15 15
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## [1] "Coefficients of final model:"
## Estimate 2.5 % 97.5 %
## (Intercept) 1.967507e+00 1.951372e+00 1.983643e+00
## x4 -5.029613e-05 -6.769517e-05 -3.289709e-05
## x7 1.044485e-02 9.210735e-03 1.167897e-02
## x8 4.600676e-04 1.745882e-04 7.455470e-04
## x9 3.012246e-03 2.373171e-03 3.651320e-03
## x10 1.124834e-03 5.308712e-04 1.718798e-03
## x11 2.144872e+05 7.225403e+04 3.567204e+05
## x16 1.235851e-03 8.222581e-04 1.649445e-03
## x17 1.500100e-03 8.677607e-04 2.132439e-03
## x21 1.289568e-04 4.739125e-05 2.105223e-04
## stat14 -8.098545e-04 -1.285739e-03 -3.339704e-04
## stat22 -6.216928e-04 -1.103225e-03 -1.401604e-04
## stat98 3.592799e-03 3.120309e-03 4.065290e-03
## stat110 -3.234551e-03 -3.714185e-03 -2.754917e-03
## stat149 -6.442636e-04 -1.125085e-03 -1.634420e-04
## x18.sqrt 2.633233e-02 2.451034e-02 2.815431e-02
if (algo.forward.caret == TRUE){
test.model(model=model.forward, test=data.test
,method = 'leapForward',subopt = NULL
,formula = formula, feature.names = feature.names, label.names = label.names
,id = id
,draw.limits = TRUE, transformation = t)
}
## [1] "Summary of predicted values: "
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.033 2.085 2.098 2.097 2.109 2.142
## [1] "leapForward Test MSE: 0.000975960779489266"
if (algo.backward.caret == TRUE){
set.seed(1)
returned = train.caret.glmselect(formula = formula
,data = data.train
,method = "leapBackward"
,feature.names = feature.names)
model.backward = returned$model
id = returned$id
}
## Aggregating results
## Selecting tuning parameters
## Fitting nvmax = 15 on full training set
## [1] "All models results"
## nvmax RMSE Rsquared MAE RMSESD RsquaredSD MAESD
## 1 1 0.03401434 0.1129284 0.02643588 0.001653505 0.02622841 0.001102860
## 2 2 0.03327509 0.1508562 0.02584895 0.001824017 0.02882595 0.001298308
## 3 3 0.03268776 0.1806362 0.02522895 0.001724857 0.02926289 0.001242842
## 4 4 0.03221824 0.2037167 0.02457710 0.001619741 0.02635159 0.001155205
## 5 5 0.03198566 0.2150295 0.02440800 0.001623696 0.02619591 0.001159999
## 6 6 0.03196348 0.2163788 0.02441940 0.001696140 0.02841727 0.001174286
## 7 7 0.03180550 0.2239996 0.02428267 0.001715946 0.03089328 0.001199637
## 8 8 0.03174826 0.2265913 0.02425835 0.001683503 0.02873522 0.001171472
## 9 9 0.03178904 0.2246853 0.02428039 0.001704478 0.02955390 0.001170683
## 10 10 0.03177374 0.2253224 0.02427874 0.001691829 0.02774504 0.001128675
## 11 11 0.03177040 0.2255159 0.02427981 0.001670797 0.02729749 0.001123762
## 12 12 0.03176208 0.2259251 0.02429125 0.001680949 0.02809431 0.001134895
## 13 13 0.03175935 0.2260897 0.02428991 0.001688991 0.02737024 0.001145900
## 14 14 0.03174727 0.2267631 0.02428874 0.001676773 0.02679936 0.001130957
## 15 15 0.03172887 0.2277161 0.02427692 0.001696985 0.02798228 0.001150043
## 16 16 0.03175348 0.2266272 0.02428481 0.001702021 0.02818457 0.001145718
## 17 17 0.03175977 0.2263111 0.02429053 0.001700435 0.02824083 0.001134139
## 18 18 0.03175003 0.2267465 0.02428602 0.001665137 0.02777001 0.001100439
## 19 19 0.03176832 0.2258468 0.02430214 0.001642422 0.02596093 0.001078176
## 20 20 0.03177849 0.2253463 0.02431685 0.001646734 0.02577676 0.001074751
## 21 21 0.03179040 0.2247855 0.02433509 0.001665307 0.02577533 0.001096565
## 22 22 0.03180154 0.2243536 0.02433803 0.001693790 0.02670486 0.001126095
## 23 23 0.03181162 0.2239417 0.02433736 0.001680680 0.02649117 0.001114057
## 24 24 0.03184851 0.2221619 0.02436201 0.001659161 0.02556554 0.001112043
## 25 25 0.03187193 0.2211479 0.02437414 0.001666901 0.02587805 0.001114698
## 26 26 0.03187155 0.2211404 0.02436642 0.001645837 0.02529189 0.001099753
## 27 27 0.03189182 0.2202059 0.02438159 0.001635787 0.02533427 0.001083287
## 28 28 0.03189784 0.2198819 0.02439306 0.001634171 0.02423439 0.001086497
## 29 29 0.03189958 0.2198300 0.02439396 0.001641098 0.02376477 0.001092837
## 30 30 0.03191455 0.2191976 0.02439731 0.001654472 0.02466238 0.001115914
## 31 31 0.03194237 0.2179452 0.02441249 0.001658650 0.02410277 0.001113901
## 32 32 0.03195286 0.2174845 0.02441208 0.001651788 0.02409170 0.001105404
## 33 33 0.03196196 0.2170881 0.02442227 0.001672674 0.02433744 0.001114408
## 34 34 0.03198134 0.2162213 0.02445104 0.001675531 0.02428745 0.001126635
## 35 35 0.03199756 0.2154614 0.02446613 0.001659385 0.02393205 0.001116851
## 36 36 0.03200400 0.2151934 0.02447151 0.001652968 0.02370249 0.001111113
## 37 37 0.03201355 0.2147458 0.02448450 0.001663654 0.02468411 0.001132306
## 38 38 0.03201878 0.2145763 0.02448134 0.001663550 0.02490018 0.001135325
## 39 39 0.03204336 0.2135089 0.02450336 0.001674571 0.02550479 0.001144138
## 40 40 0.03205355 0.2130561 0.02451627 0.001664914 0.02539890 0.001134153
## 41 41 0.03207286 0.2121986 0.02452555 0.001650586 0.02539775 0.001114299
## 42 42 0.03207647 0.2121011 0.02452683 0.001657281 0.02614148 0.001116757
## 43 43 0.03209041 0.2115280 0.02454014 0.001679544 0.02695757 0.001142453
## 44 44 0.03209237 0.2114400 0.02454570 0.001655146 0.02593967 0.001129734
## 45 45 0.03210200 0.2110876 0.02454168 0.001661222 0.02620642 0.001133127
## 46 46 0.03210079 0.2111621 0.02453816 0.001670671 0.02638869 0.001152837
## 47 47 0.03210838 0.2108429 0.02454912 0.001661589 0.02579341 0.001136427
## 48 48 0.03211396 0.2105544 0.02455616 0.001652323 0.02546929 0.001131230
## 49 49 0.03212385 0.2101253 0.02456505 0.001659707 0.02613426 0.001140207
## 50 50 0.03213477 0.2096851 0.02456653 0.001669405 0.02613567 0.001149302
## 51 51 0.03214626 0.2091846 0.02458068 0.001679783 0.02600609 0.001155686
## 52 52 0.03215654 0.2087353 0.02458482 0.001676250 0.02582136 0.001158903
## 53 53 0.03217092 0.2081214 0.02459308 0.001674522 0.02547842 0.001160118
## 54 54 0.03217773 0.2078144 0.02459150 0.001671233 0.02500103 0.001162225
## 55 55 0.03217494 0.2079510 0.02459803 0.001656497 0.02433482 0.001146291
## 56 56 0.03218941 0.2073380 0.02461093 0.001649618 0.02405603 0.001136348
## 57 57 0.03218071 0.2077893 0.02460768 0.001658105 0.02443184 0.001152351
## 58 58 0.03218854 0.2074827 0.02461394 0.001661873 0.02472914 0.001160485
## 59 59 0.03218914 0.2075072 0.02462023 0.001658479 0.02479355 0.001158666
## 60 60 0.03220941 0.2066349 0.02463187 0.001663123 0.02488023 0.001155787
## 61 61 0.03221729 0.2063021 0.02464497 0.001667543 0.02423094 0.001156354
## 62 62 0.03222910 0.2058300 0.02465510 0.001669983 0.02413817 0.001151339
## 63 63 0.03223220 0.2057394 0.02466330 0.001667892 0.02390635 0.001148018
## 64 64 0.03225002 0.2049804 0.02467402 0.001671291 0.02385610 0.001153589
## 65 65 0.03226240 0.2044765 0.02468538 0.001672505 0.02386110 0.001160834
## 66 66 0.03226222 0.2045289 0.02468547 0.001659231 0.02382977 0.001155734
## 67 67 0.03225576 0.2048488 0.02468118 0.001660619 0.02376454 0.001154303
## 68 68 0.03226220 0.2045378 0.02468267 0.001651101 0.02340498 0.001147466
## 69 69 0.03227962 0.2037742 0.02470042 0.001641096 0.02335876 0.001143339
## 70 70 0.03228987 0.2033240 0.02471208 0.001638843 0.02330447 0.001141381
## 71 71 0.03229196 0.2032478 0.02472214 0.001638012 0.02301485 0.001138066
## 72 72 0.03228315 0.2036559 0.02471410 0.001634923 0.02329780 0.001133913
## 73 73 0.03228746 0.2034807 0.02471884 0.001632736 0.02311745 0.001132121
## 74 74 0.03228963 0.2034098 0.02472369 0.001637963 0.02342776 0.001133960
## 75 75 0.03229336 0.2032978 0.02472229 0.001624107 0.02282409 0.001124781
## 76 76 0.03229271 0.2033336 0.02471554 0.001635522 0.02306388 0.001136543
## 77 77 0.03230305 0.2028993 0.02473015 0.001631705 0.02269890 0.001129301
## 78 78 0.03229746 0.2031795 0.02473070 0.001630776 0.02248540 0.001116127
## 79 79 0.03228562 0.2037362 0.02471934 0.001632176 0.02269442 0.001123400
## 80 80 0.03228785 0.2036901 0.02472046 0.001643777 0.02317772 0.001133161
## 81 81 0.03228544 0.2038206 0.02471505 0.001637500 0.02359442 0.001133428
## 82 82 0.03229446 0.2034355 0.02472393 0.001631534 0.02336606 0.001128067
## 83 83 0.03228701 0.2037651 0.02471621 0.001629277 0.02338391 0.001126932
## 84 84 0.03229363 0.2034711 0.02472435 0.001622269 0.02281306 0.001118292
## 85 85 0.03229354 0.2034310 0.02473527 0.001625932 0.02273212 0.001113649
## 86 86 0.03228879 0.2036498 0.02472971 0.001628786 0.02304798 0.001118666
## 87 87 0.03228578 0.2038363 0.02472793 0.001632383 0.02329869 0.001119388
## 88 88 0.03229067 0.2036772 0.02473850 0.001640247 0.02358460 0.001125042
## 89 89 0.03229457 0.2034834 0.02474285 0.001637991 0.02344374 0.001117534
## 90 90 0.03228365 0.2039560 0.02473459 0.001628919 0.02321355 0.001111661
## 91 91 0.03228805 0.2037606 0.02473383 0.001623485 0.02272839 0.001104579
## 92 92 0.03228658 0.2038823 0.02472687 0.001628954 0.02276895 0.001108919
## 93 93 0.03227524 0.2044053 0.02472069 0.001627938 0.02281031 0.001114124
## 94 94 0.03227224 0.2045516 0.02471856 0.001634192 0.02309068 0.001118295
## 95 95 0.03227142 0.2046055 0.02471809 0.001627321 0.02288451 0.001115475
## 96 96 0.03226775 0.2047727 0.02471607 0.001626642 0.02285167 0.001112228
## 97 97 0.03228203 0.2041774 0.02472947 0.001625810 0.02292948 0.001113936
## 98 98 0.03227698 0.2043886 0.02472928 0.001623673 0.02288169 0.001108168
## 99 99 0.03227571 0.2044167 0.02472991 0.001621421 0.02242876 0.001110873
## 100 100 0.03227600 0.2044158 0.02472731 0.001615593 0.02236397 0.001108287
## 101 101 0.03228431 0.2041144 0.02473737 0.001620349 0.02260499 0.001105970
## 102 102 0.03227893 0.2043411 0.02473309 0.001622913 0.02272116 0.001109345
## 103 103 0.03227692 0.2044309 0.02472949 0.001625963 0.02285966 0.001108230
## 104 104 0.03227755 0.2044214 0.02473077 0.001626088 0.02319240 0.001103517
## 105 105 0.03228242 0.2042319 0.02473674 0.001624980 0.02320318 0.001102138
## 106 106 0.03227993 0.2043483 0.02473142 0.001638687 0.02360391 0.001105532
## 107 107 0.03227429 0.2046101 0.02472714 0.001635157 0.02360670 0.001096334
## 108 108 0.03228524 0.2041609 0.02473704 0.001636202 0.02339664 0.001095591
## 109 109 0.03228884 0.2040406 0.02473889 0.001636229 0.02360733 0.001090025
## 110 110 0.03228652 0.2041728 0.02473450 0.001633181 0.02335092 0.001092634
## 111 111 0.03228165 0.2044240 0.02473171 0.001635483 0.02371541 0.001091767
## 112 112 0.03228922 0.2041119 0.02473367 0.001638286 0.02412663 0.001094312
## 113 113 0.03229642 0.2038357 0.02474020 0.001640384 0.02416475 0.001094740
## 114 114 0.03230341 0.2035269 0.02474332 0.001634024 0.02378869 0.001085566
## 115 115 0.03230455 0.2034581 0.02474371 0.001622543 0.02364606 0.001079527
## 116 116 0.03230755 0.2033600 0.02474910 0.001620599 0.02376917 0.001075205
## 117 117 0.03230381 0.2035316 0.02474079 0.001622758 0.02393898 0.001070757
## 118 118 0.03230899 0.2033568 0.02474323 0.001623165 0.02398724 0.001070863
## 119 119 0.03230494 0.2035781 0.02474408 0.001632547 0.02461399 0.001075094
## 120 120 0.03230818 0.2034758 0.02474704 0.001637022 0.02495115 0.001073676
## 121 121 0.03232019 0.2029749 0.02475530 0.001636382 0.02492034 0.001077400
## 122 122 0.03232760 0.2026723 0.02476370 0.001641130 0.02489727 0.001083717
## 123 123 0.03232620 0.2027590 0.02476006 0.001649277 0.02525077 0.001092266
## 124 124 0.03232531 0.2028002 0.02475764 0.001657909 0.02562391 0.001099211
## 125 125 0.03232201 0.2029606 0.02475512 0.001651491 0.02535275 0.001094008
## 126 126 0.03232153 0.2029540 0.02475594 0.001651505 0.02519864 0.001090106
## 127 127 0.03232239 0.2029499 0.02475606 0.001654155 0.02518760 0.001095197
## 128 128 0.03232615 0.2027950 0.02475539 0.001652796 0.02514199 0.001098900
## 129 129 0.03233331 0.2025120 0.02475945 0.001649622 0.02505014 0.001100444
## 130 130 0.03233955 0.2022523 0.02476518 0.001644261 0.02507651 0.001097800
## 131 131 0.03233527 0.2024475 0.02476197 0.001647242 0.02542028 0.001094825
## 132 132 0.03233486 0.2024500 0.02476105 0.001654094 0.02562530 0.001095687
## 133 133 0.03234238 0.2021166 0.02476816 0.001654690 0.02567979 0.001096251
## 134 134 0.03234658 0.2019492 0.02477466 0.001658955 0.02578012 0.001101696
## 135 135 0.03235016 0.2018042 0.02477757 0.001656638 0.02576257 0.001103197
## 136 136 0.03235474 0.2016119 0.02478217 0.001659125 0.02578020 0.001103934
## 137 137 0.03235405 0.2016458 0.02478380 0.001655803 0.02592014 0.001098978
## 138 138 0.03235543 0.2015766 0.02478347 0.001661621 0.02602388 0.001104539
## 139 139 0.03235448 0.2016510 0.02478439 0.001666490 0.02609405 0.001110976
## 140 140 0.03236202 0.2013647 0.02478842 0.001674094 0.02631081 0.001110967
## 141 141 0.03236053 0.2014452 0.02478430 0.001670084 0.02629943 0.001106614
## 142 142 0.03236327 0.2013134 0.02478527 0.001662689 0.02618984 0.001099193
## 143 143 0.03236659 0.2011974 0.02478982 0.001667191 0.02627480 0.001100256
## 144 144 0.03237176 0.2009667 0.02479462 0.001665014 0.02612968 0.001098942
## 145 145 0.03237304 0.2009189 0.02479458 0.001660856 0.02619250 0.001096912
## 146 146 0.03237770 0.2007260 0.02480155 0.001658867 0.02587160 0.001097020
## 147 147 0.03237278 0.2009598 0.02479860 0.001666279 0.02629324 0.001099569
## 148 148 0.03237718 0.2007604 0.02480012 0.001668257 0.02636600 0.001100107
## 149 149 0.03237710 0.2007820 0.02479617 0.001669787 0.02644429 0.001103016
## 150 150 0.03237603 0.2008477 0.02479319 0.001672100 0.02638452 0.001112143
## 151 151 0.03237770 0.2007672 0.02479297 0.001669102 0.02650326 0.001109851
## 152 152 0.03237988 0.2006811 0.02479148 0.001670830 0.02670625 0.001107572
## 153 153 0.03238592 0.2004328 0.02479219 0.001670575 0.02678263 0.001107394
## 154 154 0.03238544 0.2004575 0.02479179 0.001669457 0.02668808 0.001108334
## 155 155 0.03238753 0.2003422 0.02479404 0.001670555 0.02676225 0.001109997
## 156 156 0.03239255 0.2001387 0.02479676 0.001669950 0.02669968 0.001109468
## 157 157 0.03239348 0.2000960 0.02479552 0.001668485 0.02656353 0.001107511
## 158 158 0.03239238 0.2001359 0.02479667 0.001663534 0.02624668 0.001106288
## 159 159 0.03239176 0.2001586 0.02479386 0.001661681 0.02619369 0.001108592
## 160 160 0.03239355 0.2000662 0.02479606 0.001659569 0.02608123 0.001110204
## 161 161 0.03239605 0.1999662 0.02479561 0.001662583 0.02606922 0.001112945
## 162 162 0.03239805 0.1998893 0.02479468 0.001660010 0.02612716 0.001110695
## 163 163 0.03239649 0.1999441 0.02479242 0.001660548 0.02621300 0.001107798
## 164 164 0.03239804 0.1998657 0.02479888 0.001656195 0.02604970 0.001103785
## 165 165 0.03239982 0.1997957 0.02479944 0.001655344 0.02614368 0.001103904
## 166 166 0.03240076 0.1997413 0.02479963 0.001657336 0.02613108 0.001106677
## 167 167 0.03240336 0.1996433 0.02480179 0.001657308 0.02613126 0.001104849
## 168 168 0.03240332 0.1996696 0.02479883 0.001660595 0.02614497 0.001106112
## 169 169 0.03240258 0.1996988 0.02479763 0.001659712 0.02615743 0.001106697
## 170 170 0.03240324 0.1996646 0.02479790 0.001662753 0.02617729 0.001111408
## 171 171 0.03240794 0.1994512 0.02480490 0.001659228 0.02595378 0.001109299
## 172 172 0.03240583 0.1995239 0.02480395 0.001658693 0.02596777 0.001109422
## 173 173 0.03240899 0.1993923 0.02480690 0.001661750 0.02603804 0.001112069
## 174 174 0.03241029 0.1993368 0.02480983 0.001664182 0.02605364 0.001116362
## 175 175 0.03240922 0.1993815 0.02480860 0.001662166 0.02590927 0.001113096
## 176 176 0.03241338 0.1992239 0.02481234 0.001668821 0.02607627 0.001117117
## 177 177 0.03241017 0.1993653 0.02481099 0.001667773 0.02608223 0.001115467
## 178 178 0.03241393 0.1991963 0.02481377 0.001668284 0.02606685 0.001113976
## 179 179 0.03241165 0.1992964 0.02481252 0.001668491 0.02606235 0.001114721
## 180 180 0.03241131 0.1993114 0.02481392 0.001669224 0.02618128 0.001114701
## 181 181 0.03240932 0.1994042 0.02481230 0.001665697 0.02604145 0.001111078
## 182 182 0.03241012 0.1993797 0.02481307 0.001668306 0.02602410 0.001112747
## 183 183 0.03241194 0.1992886 0.02481557 0.001666933 0.02596594 0.001110414
## 184 184 0.03241206 0.1992871 0.02481639 0.001668296 0.02594878 0.001110863
## 185 185 0.03241254 0.1992715 0.02481719 0.001667099 0.02586981 0.001110155
## 186 186 0.03241242 0.1992930 0.02481707 0.001668785 0.02595456 0.001113083
## 187 187 0.03241470 0.1991869 0.02481873 0.001667535 0.02583291 0.001112258
## 188 188 0.03241580 0.1991545 0.02481964 0.001669489 0.02595044 0.001115977
## 189 189 0.03241555 0.1991533 0.02482205 0.001668537 0.02592897 0.001115508
## 190 190 0.03241560 0.1991585 0.02482117 0.001669040 0.02598447 0.001115022
## 191 191 0.03241586 0.1991461 0.02482046 0.001668338 0.02597838 0.001114630
## 192 192 0.03241251 0.1992828 0.02481936 0.001667753 0.02603538 0.001115434
## 193 193 0.03241231 0.1992892 0.02481827 0.001667457 0.02602182 0.001115874
## 194 194 0.03241303 0.1992514 0.02481974 0.001666355 0.02590066 0.001115345
## 195 195 0.03241199 0.1992954 0.02481992 0.001666516 0.02597076 0.001115056
## 196 196 0.03241227 0.1992735 0.02482162 0.001666074 0.02593653 0.001114849
## 197 197 0.03241232 0.1992610 0.02482079 0.001663172 0.02577365 0.001112962
## 198 198 0.03241550 0.1991213 0.02482317 0.001663885 0.02574164 0.001114105
## 199 199 0.03241858 0.1989849 0.02482486 0.001663714 0.02570489 0.001114228
## 200 200 0.03242125 0.1988780 0.02482672 0.001666073 0.02572705 0.001115908
## 201 201 0.03242148 0.1988742 0.02482642 0.001666002 0.02574534 0.001115770
## 202 202 0.03242024 0.1989189 0.02482707 0.001665934 0.02570841 0.001115722
## 203 203 0.03242174 0.1988564 0.02482805 0.001665860 0.02569423 0.001115600
## 204 204 0.03242247 0.1988211 0.02482887 0.001666421 0.02570974 0.001117567
## 205 205 0.03242220 0.1988275 0.02482759 0.001664984 0.02569562 0.001116582
## 206 206 0.03242274 0.1987923 0.02482911 0.001663824 0.02562022 0.001116856
## 207 207 0.03242236 0.1988121 0.02482884 0.001664084 0.02561466 0.001117797
## 208 208 0.03242239 0.1988269 0.02482930 0.001663959 0.02564869 0.001118665
## 209 209 0.03242237 0.1988304 0.02482881 0.001664078 0.02563573 0.001118633
## 210 210 0.03242222 0.1988449 0.02482784 0.001664957 0.02574449 0.001118248
## 211 211 0.03242127 0.1988851 0.02482792 0.001664835 0.02580157 0.001118328
## 212 212 0.03241932 0.1989708 0.02482519 0.001663164 0.02579171 0.001116751
## 213 213 0.03241911 0.1989842 0.02482540 0.001663162 0.02574791 0.001117353
## 214 214 0.03241798 0.1990293 0.02482471 0.001662374 0.02573303 0.001116862
## 215 215 0.03241820 0.1990202 0.02482473 0.001662506 0.02575708 0.001117873
## 216 216 0.03241661 0.1990887 0.02482411 0.001661291 0.02570533 0.001118090
## 217 217 0.03241672 0.1990814 0.02482366 0.001661302 0.02571403 0.001118959
## 218 218 0.03241534 0.1991370 0.02482213 0.001661462 0.02570781 0.001119755
## 219 219 0.03241515 0.1991480 0.02482193 0.001662119 0.02569389 0.001119940
## 220 220 0.03241499 0.1991551 0.02482232 0.001662201 0.02569115 0.001120470
## 221 221 0.03241610 0.1991075 0.02482339 0.001662241 0.02566495 0.001119904
## 222 222 0.03241613 0.1991058 0.02482436 0.001661326 0.02564961 0.001119450
## 223 223 0.03241696 0.1990707 0.02482530 0.001661515 0.02564111 0.001118923
## 224 224 0.03241684 0.1990743 0.02482600 0.001661420 0.02564742 0.001118575
## 225 225 0.03241777 0.1990315 0.02482636 0.001661908 0.02565946 0.001119507
## 226 226 0.03241783 0.1990293 0.02482596 0.001661740 0.02567120 0.001119412
## 227 227 0.03241807 0.1990222 0.02482588 0.001662327 0.02568653 0.001119877
## 228 228 0.03241771 0.1990394 0.02482622 0.001662357 0.02571741 0.001120231
## 229 229 0.03241783 0.1990376 0.02482649 0.001662633 0.02575663 0.001120400
## 230 230 0.03241756 0.1990477 0.02482596 0.001663162 0.02578357 0.001120430
## 231 231 0.03241816 0.1990219 0.02482649 0.001663076 0.02576580 0.001120536
## 232 232 0.03241806 0.1990258 0.02482641 0.001663205 0.02577734 0.001120702
## 233 233 0.03241819 0.1990201 0.02482649 0.001662966 0.02578684 0.001120359
## 234 234 0.03241791 0.1990320 0.02482610 0.001663157 0.02579253 0.001120550
## 235 235 0.03241782 0.1990370 0.02482623 0.001662943 0.02578869 0.001120480
## 236 236 0.03241774 0.1990414 0.02482617 0.001663055 0.02579726 0.001120485
## 237 237 0.03241764 0.1990444 0.02482617 0.001663121 0.02579756 0.001120597
## 238 238 0.03241757 0.1990470 0.02482614 0.001663087 0.02579691 0.001120563
## 239 239 0.03241743 0.1990526 0.02482609 0.001662957 0.02579164 0.001120500
## 240 240 0.03241747 0.1990510 0.02482615 0.001663024 0.02579431 0.001120562
## [1] "Best Model"
## nvmax
## 15 15
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## [1] "Coefficients of final model:"
## Estimate 2.5 % 97.5 %
## (Intercept) 1.967507e+00 1.951372e+00 1.983643e+00
## x4 -5.029613e-05 -6.769517e-05 -3.289709e-05
## x7 1.044485e-02 9.210735e-03 1.167897e-02
## x8 4.600676e-04 1.745882e-04 7.455470e-04
## x9 3.012246e-03 2.373171e-03 3.651320e-03
## x10 1.124834e-03 5.308712e-04 1.718798e-03
## x11 2.144872e+05 7.225403e+04 3.567204e+05
## x16 1.235851e-03 8.222581e-04 1.649445e-03
## x17 1.500100e-03 8.677607e-04 2.132439e-03
## x21 1.289568e-04 4.739125e-05 2.105223e-04
## stat14 -8.098545e-04 -1.285739e-03 -3.339704e-04
## stat22 -6.216928e-04 -1.103225e-03 -1.401604e-04
## stat98 3.592799e-03 3.120309e-03 4.065290e-03
## stat110 -3.234551e-03 -3.714185e-03 -2.754917e-03
## stat149 -6.442636e-04 -1.125085e-03 -1.634420e-04
## x18.sqrt 2.633233e-02 2.451034e-02 2.815431e-02
if (algo.backward.caret == TRUE){
test.model(model.backward, data.test
,method = 'leapBackward',subopt = NULL
,formula = formula, feature.names = feature.names, label.names = label.names
,id = id
,draw.limits = TRUE, transformation = t)
}
## [1] "Summary of predicted values: "
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.033 2.085 2.098 2.097 2.109 2.142
## [1] "leapBackward Test MSE: 0.000975960779489266"
if (algo.stepwise.caret == TRUE){
set.seed(1)
returned = train.caret.glmselect(formula = formula
,data = data.train
,method = "leapSeq"
,feature.names = feature.names)
model.stepwise = returned$model
id = returned$id
}
## Aggregating results
## Selecting tuning parameters
## Fitting nvmax = 15 on full training set
## [1] "All models results"
## nvmax RMSE Rsquared MAE RMSESD RsquaredSD MAESD
## 1 1 0.03401434 0.1129284 0.02643588 0.001653505 0.02622841 0.0011028596
## 2 2 0.03327509 0.1508562 0.02584895 0.001824017 0.02882595 0.0012983084
## 3 3 0.03268776 0.1806362 0.02522895 0.001724857 0.02926289 0.0012428418
## 4 4 0.03221824 0.2037167 0.02457710 0.001619741 0.02635159 0.0011552055
## 5 5 0.03198566 0.2150295 0.02440800 0.001623696 0.02619591 0.0011599993
## 6 6 0.03196348 0.2163788 0.02441940 0.001696140 0.02841727 0.0011742856
## 7 7 0.03180550 0.2239996 0.02428267 0.001715946 0.03089328 0.0011996369
## 8 8 0.03174826 0.2265913 0.02425835 0.001683503 0.02873522 0.0011714720
## 9 9 0.03178904 0.2246853 0.02428039 0.001704478 0.02955390 0.0011706832
## 10 10 0.03177374 0.2253224 0.02427874 0.001691829 0.02774504 0.0011286754
## 11 11 0.03177040 0.2255159 0.02427981 0.001670797 0.02729749 0.0011237625
## 12 12 0.03176208 0.2259251 0.02429125 0.001680949 0.02809431 0.0011348954
## 13 13 0.03175935 0.2260897 0.02428991 0.001688991 0.02737024 0.0011459004
## 14 14 0.03174727 0.2267631 0.02428874 0.001676773 0.02679936 0.0011309569
## 15 15 0.03172887 0.2277161 0.02427692 0.001696985 0.02798228 0.0011500434
## 16 16 0.03175348 0.2266272 0.02428481 0.001702021 0.02818457 0.0011457179
## 17 17 0.03206444 0.2109655 0.02451358 0.002194672 0.06313721 0.0014994882
## 18 18 0.03175003 0.2267465 0.02428602 0.001665137 0.02777001 0.0011004389
## 19 19 0.03214303 0.2055958 0.02461990 0.001317680 0.05425794 0.0008439660
## 20 20 0.03177849 0.2253463 0.02431685 0.001646734 0.02577676 0.0010747508
## 21 21 0.03179040 0.2247855 0.02433509 0.001665307 0.02577533 0.0010965654
## 22 22 0.03180574 0.2241727 0.02434164 0.001696696 0.02671741 0.0011302383
## 23 23 0.03181246 0.2239205 0.02434062 0.001684177 0.02648960 0.0011146907
## 24 24 0.03184966 0.2221161 0.02436100 0.001659953 0.02556547 0.0011108724
## 25 25 0.03187019 0.2211773 0.02436632 0.001669196 0.02587348 0.0011205983
## 26 26 0.03250381 0.1888801 0.02495444 0.002244775 0.07303781 0.0017187798
## 27 27 0.03211741 0.2074997 0.02456334 0.001483839 0.04880065 0.0011074442
## 28 28 0.03189075 0.2202171 0.02438434 0.001635757 0.02421663 0.0010901348
## 29 29 0.03213757 0.2065274 0.02459099 0.001463685 0.04797825 0.0010997221
## 30 30 0.03249771 0.1898242 0.02482952 0.002418352 0.07401254 0.0017226152
## 31 31 0.03228152 0.1995812 0.02470678 0.001302369 0.04767336 0.0008573188
## 32 32 0.03258683 0.1861198 0.02490156 0.002647267 0.07643979 0.0018825450
## 33 33 0.03195319 0.2174742 0.02442165 0.001647238 0.02376143 0.0011078370
## 34 34 0.03262077 0.1836188 0.02503088 0.002241282 0.07126069 0.0017274456
## 35 35 0.03199660 0.2155346 0.02446352 0.001655760 0.02410613 0.0011286020
## 36 36 0.03228777 0.2004763 0.02469530 0.001684752 0.04550704 0.0012560910
## 37 37 0.03331477 0.1484894 0.02556535 0.002269138 0.07860681 0.0015806007
## 38 38 0.03291903 0.1678050 0.02517469 0.002031300 0.07435351 0.0014021506
## 39 39 0.03204275 0.2135917 0.02449645 0.001690206 0.02585637 0.0011420426
## 40 40 0.03296737 0.1653948 0.02524930 0.001623385 0.06464516 0.0010728143
## 41 41 0.03241825 0.1936417 0.02480632 0.001291442 0.04693351 0.0008045908
## 42 42 0.03239022 0.1958657 0.02482728 0.001844065 0.05527604 0.0012723186
## 43 43 0.03273787 0.1771919 0.02513165 0.001444838 0.06274835 0.0008985786
## 44 44 0.03323699 0.1528356 0.02544255 0.002547447 0.08026996 0.0019248498
## 45 45 0.03235273 0.1980189 0.02472547 0.002075100 0.05724407 0.0014270292
## 46 46 0.03300420 0.1649808 0.02528495 0.002429234 0.07611030 0.0019454112
## 47 47 0.03211235 0.2106840 0.02455083 0.001669872 0.02623471 0.0011451270
## 48 48 0.03263821 0.1822700 0.02506306 0.001649335 0.06448309 0.0012482264
## 49 49 0.03213880 0.2095008 0.02457078 0.001667150 0.02598830 0.0011444590
## 50 50 0.03246475 0.1937045 0.02483119 0.002284708 0.05683085 0.0016416954
## 51 51 0.03250667 0.1899744 0.02489496 0.001274678 0.04499547 0.0007997801
## 52 52 0.03251844 0.1907765 0.02488882 0.002139593 0.05601955 0.0016825508
## 53 53 0.03218520 0.2074853 0.02460408 0.001680245 0.02569057 0.0011566429
## 54 54 0.03248482 0.1918802 0.02483764 0.001696982 0.04576401 0.0012992711
## 55 55 0.03244137 0.1942300 0.02481074 0.002080333 0.05592574 0.0014561591
## 56 56 0.03247961 0.1927773 0.02485369 0.002063278 0.05303584 0.0014017893
## 57 57 0.03282353 0.1719006 0.02516600 0.001951148 0.07544187 0.0014741796
## 58 58 0.03245530 0.1939349 0.02483357 0.002088400 0.05350510 0.0014171075
## 59 59 0.03245929 0.1939068 0.02480721 0.002032351 0.05203691 0.0014522380
## 60 60 0.03279543 0.1771452 0.02508105 0.002381620 0.06860525 0.0018499568
## 61 61 0.03281689 0.1761641 0.02514179 0.002400831 0.06853259 0.0017976515
## 62 62 0.03249214 0.1925243 0.02482792 0.002026997 0.05182746 0.0014422530
## 63 63 0.03272874 0.1791926 0.02511096 0.002180183 0.06838249 0.0017070295
## 64 64 0.03306454 0.1622283 0.02534545 0.002050879 0.06837558 0.0016123300
## 65 65 0.03280207 0.1763863 0.02516193 0.002147267 0.06743471 0.0014775109
## 66 66 0.03269351 0.1807722 0.02505395 0.002121355 0.06763452 0.0014955804
## 67 67 0.03226483 0.2044421 0.02468764 0.001668494 0.02341296 0.0011662386
## 68 68 0.03226478 0.2044286 0.02468558 0.001666144 0.02389298 0.0011652132
## 69 69 0.03262107 0.1854286 0.02498466 0.001249269 0.04348572 0.0007963032
## 70 70 0.03255918 0.1890959 0.02497699 0.001809519 0.05168830 0.0012859506
## 71 71 0.03261032 0.1859698 0.02499245 0.001241030 0.04321487 0.0007949536
## 72 72 0.03321139 0.1577092 0.02540939 0.002755707 0.07796841 0.0021033744
## 73 73 0.03298394 0.1656754 0.02532317 0.002041014 0.07129820 0.0014878511
## 74 74 0.03228327 0.2037517 0.02471874 0.001638846 0.02334875 0.0011384769
## 75 75 0.03295364 0.1695294 0.02526005 0.001928746 0.06154688 0.0013208723
## 76 76 0.03271973 0.1799920 0.02508454 0.002088526 0.06577952 0.0014351186
## 77 77 0.03250844 0.1908755 0.02490986 0.001449528 0.04485167 0.0011223007
## 78 78 0.03295746 0.1707017 0.02524681 0.002565217 0.06985802 0.0019467604
## 79 79 0.03257449 0.1886397 0.02500205 0.001776260 0.05095803 0.0012417906
## 80 80 0.03316411 0.1575984 0.02548874 0.001708500 0.06749191 0.0010147627
## 81 81 0.03307350 0.1619718 0.02542449 0.002221264 0.07734206 0.0017000431
## 82 82 0.03229061 0.2036087 0.02471179 0.001636826 0.02330872 0.0011311823
## 83 83 0.03262632 0.1868525 0.02498852 0.002095519 0.05479223 0.0016271073
## 84 84 0.03275192 0.1787173 0.02507156 0.002085890 0.06736939 0.0014994144
## 85 85 0.03321907 0.1549295 0.02550772 0.001647625 0.06428258 0.0013549780
## 86 86 0.03328198 0.1508014 0.02551776 0.002402469 0.08281620 0.0017389507
## 87 87 0.03228488 0.2039189 0.02473562 0.001630830 0.02335386 0.0011034536
## 88 88 0.03257383 0.1892871 0.02494192 0.002060085 0.05477581 0.0013741006
## 89 89 0.03257649 0.1892073 0.02494040 0.002066591 0.05489752 0.0013852654
## 90 90 0.03283803 0.1750762 0.02519661 0.002002383 0.06213163 0.0014341643
## 91 91 0.03229698 0.2034541 0.02474503 0.001632224 0.02324343 0.0011049377
## 92 92 0.03258301 0.1891117 0.02493364 0.002027120 0.05287455 0.0014228220
## 93 93 0.03304903 0.1638190 0.02531375 0.002140052 0.07220758 0.0015435360
## 94 94 0.03246428 0.1933323 0.02488758 0.001774365 0.05295594 0.0012456497
## 95 95 0.03259284 0.1884901 0.02498461 0.002087789 0.05412110 0.0016161376
## 96 96 0.03261258 0.1882501 0.02499424 0.002298767 0.05699648 0.0016630436
## 97 97 0.03300158 0.1652211 0.02532934 0.002057178 0.07337230 0.0014809526
## 98 98 0.03345643 0.1445703 0.02567312 0.002617120 0.08351665 0.0019331891
## 99 99 0.03294791 0.1671876 0.02529478 0.001888154 0.07322293 0.0013598843
## 100 100 0.03287262 0.1738470 0.02518035 0.002032279 0.06506466 0.0015643397
## 101 101 0.03228132 0.2042434 0.02472874 0.001627242 0.02336352 0.0011082874
## 102 102 0.03260369 0.1868793 0.02500647 0.001242104 0.04328665 0.0007549912
## 103 103 0.03291016 0.1729986 0.02521414 0.002397935 0.07003013 0.0018602113
## 104 104 0.03279125 0.1759676 0.02517462 0.001370708 0.06085255 0.0008719858
## 105 105 0.03328186 0.1537817 0.02556679 0.002263277 0.07108730 0.0017230143
## 106 106 0.03291344 0.1729001 0.02522661 0.002404325 0.07016072 0.0018658966
## 107 107 0.03262997 0.1876371 0.02501447 0.002294528 0.05626876 0.0016465073
## 108 108 0.03314918 0.1596499 0.02546207 0.002327050 0.07378182 0.0018043083
## 109 109 0.03257385 0.1895828 0.02492604 0.002059456 0.05458835 0.0013739372
## 110 110 0.03289364 0.1735112 0.02524204 0.002148245 0.06789440 0.0015205738
## 111 111 0.03305882 0.1624658 0.02539247 0.001753960 0.07186899 0.0010745397
## 112 112 0.03229835 0.2037367 0.02473685 0.001635951 0.02400001 0.0010923628
## 113 113 0.03229482 0.2038396 0.02474034 0.001638344 0.02376451 0.0010968095
## 114 114 0.03261506 0.1882042 0.02496552 0.002063896 0.05490034 0.0014634566
## 115 115 0.03361601 0.1343346 0.02589038 0.002371414 0.08525429 0.0016541353
## 116 116 0.03264483 0.1865639 0.02503704 0.002096711 0.05498877 0.0016284240
## 117 117 0.03261236 0.1883247 0.02496670 0.002061670 0.05521925 0.0014575536
## 118 118 0.03338036 0.1457032 0.02564948 0.001654605 0.07587359 0.0011081997
## 119 119 0.03262629 0.1878670 0.02497760 0.002075768 0.05576566 0.0014674712
## 120 120 0.03252391 0.1919071 0.02491340 0.001630496 0.03957787 0.0011540329
## 121 121 0.03309752 0.1640472 0.02542284 0.002234129 0.06461930 0.0016795592
## 122 122 0.03258217 0.1895586 0.02500983 0.001745275 0.04640000 0.0011454174
## 123 123 0.03259946 0.1891478 0.02500495 0.001977500 0.04602470 0.0015128234
## 124 124 0.03300440 0.1687039 0.02529514 0.002417946 0.06890697 0.0016662179
## 125 125 0.03257350 0.1895931 0.02496026 0.001476185 0.04834021 0.0011169360
## 126 126 0.03254727 0.1915164 0.02492668 0.001974675 0.04855876 0.0013310641
## 127 127 0.03232153 0.2029851 0.02475569 0.001652642 0.02520058 0.0010948364
## 128 128 0.03257433 0.1895487 0.02496351 0.001473335 0.04817835 0.0011213601
## 129 129 0.03289050 0.1737329 0.02523958 0.001608950 0.04829278 0.0012136395
## 130 130 0.03306900 0.1649650 0.02539991 0.002071889 0.05976104 0.0014810799
## 131 131 0.03233185 0.2025632 0.02475994 0.001645547 0.02538642 0.0010918386
## 132 132 0.03267870 0.1842408 0.02502697 0.001823499 0.04608019 0.0012717573
## 133 133 0.03233836 0.2022724 0.02476608 0.001650099 0.02566741 0.0010898807
## 134 134 0.03234108 0.2021869 0.02476832 0.001656163 0.02589855 0.0010954175
## 135 135 0.03279062 0.1799568 0.02511432 0.001754052 0.05521837 0.0013228049
## 136 136 0.03235807 0.2014833 0.02478327 0.001661997 0.02586826 0.0011045347
## 137 137 0.03255512 0.1914497 0.02494978 0.001868273 0.03779094 0.0013625658
## 138 138 0.03306970 0.1642444 0.02534843 0.001755331 0.05773348 0.0012740594
## 139 139 0.03249571 0.1941728 0.02488761 0.001857086 0.03942406 0.0011920233
## 140 140 0.03236155 0.2013668 0.02478608 0.001673968 0.02633410 0.0011112685
## 141 141 0.03284852 0.1741064 0.02518579 0.001503225 0.04852244 0.0009126194
## 142 142 0.03236156 0.2013947 0.02478221 0.001664649 0.02627363 0.0011005369
## 143 143 0.03236602 0.2012424 0.02478322 0.001672712 0.02645275 0.0011020062
## 144 144 0.03278432 0.1806095 0.02510076 0.002095259 0.05002206 0.0015384312
## 145 145 0.03237377 0.2008984 0.02479473 0.001661227 0.02618151 0.0010970704
## 146 146 0.03237690 0.2007521 0.02480046 0.001658297 0.02588431 0.0010958361
## 147 147 0.03252594 0.1928273 0.02491840 0.001861260 0.04053640 0.0012375127
## 148 148 0.03246477 0.1946532 0.02489396 0.001709253 0.04085018 0.0011508970
## 149 149 0.03285264 0.1745578 0.02520337 0.001853581 0.05136690 0.0014273827
## 150 150 0.03260689 0.1891565 0.02499681 0.001501988 0.04480277 0.0011278006
## 151 151 0.03278620 0.1801488 0.02515961 0.001971862 0.04550450 0.0014935517
## 152 152 0.03237819 0.2007557 0.02479054 0.001669073 0.02664179 0.0011072442
## 153 153 0.03286103 0.1771845 0.02516624 0.001999431 0.05582568 0.0013450261
## 154 154 0.03238298 0.2005499 0.02478946 0.001667611 0.02654405 0.0011069955
## 155 155 0.03260168 0.1899737 0.02500417 0.002014337 0.03998462 0.0014603286
## 156 156 0.03260598 0.1897980 0.02500760 0.002012688 0.03990963 0.0014594781
## 157 157 0.03261783 0.1894205 0.02495619 0.001956190 0.04613639 0.0013713406
## 158 158 0.03261531 0.1893939 0.02501396 0.002025781 0.04058825 0.0014715112
## 159 159 0.03239045 0.2002100 0.02479280 0.001657961 0.02611324 0.0011044963
## 160 160 0.03248830 0.1936791 0.02489028 0.001708234 0.04169251 0.0011636675
## 161 161 0.03239625 0.1999569 0.02479616 0.001662452 0.02606409 0.0011128582
## 162 162 0.03292526 0.1722275 0.02527468 0.002204582 0.05454406 0.0016736126
## 163 163 0.03239916 0.1998226 0.02479641 0.001658185 0.02616526 0.0011067244
## 164 164 0.03274750 0.1814160 0.02507704 0.001819527 0.04764959 0.0013012064
## 165 165 0.03239918 0.1998215 0.02479967 0.001654886 0.02613508 0.0011034698
## 166 166 0.03278017 0.1802718 0.02511778 0.001705242 0.05284472 0.0011876572
## 167 167 0.03261092 0.1888169 0.02497650 0.001648381 0.03919726 0.0012063746
## 168 168 0.03240307 0.1996735 0.02479781 0.001660347 0.02614156 0.0011053862
## 169 169 0.03305550 0.1673540 0.02531600 0.002083427 0.05533826 0.0016334200
## 170 170 0.03291456 0.1722155 0.02525174 0.001946777 0.06017784 0.0012768254
## 171 171 0.03240844 0.1994291 0.02480448 0.001659622 0.02597122 0.0011098408
## 172 172 0.03264960 0.1882103 0.02498493 0.001979779 0.04712272 0.0014081457
## 173 173 0.03250507 0.1930446 0.02490607 0.001711327 0.04146185 0.0011677271
## 174 174 0.03241102 0.1993065 0.02480963 0.001664697 0.02606782 0.0011161495
## 175 175 0.03240922 0.1993815 0.02480860 0.001662166 0.02590927 0.0011130963
## 176 176 0.03307120 0.1667639 0.02533381 0.002102221 0.05618104 0.0016524572
## 177 177 0.03241017 0.1993653 0.02481099 0.001667773 0.02608223 0.0011154671
## 178 178 0.03241202 0.1992881 0.02481172 0.001672370 0.02627175 0.0011187910
## 179 179 0.03241165 0.1992964 0.02481252 0.001668491 0.02606235 0.0011147208
## 180 180 0.03269228 0.1848031 0.02501932 0.001256724 0.03301180 0.0007675867
## 181 181 0.03240932 0.1994042 0.02481230 0.001665697 0.02604145 0.0011110781
## 182 182 0.03269146 0.1848576 0.02501934 0.001256030 0.03299519 0.0007662943
## 183 183 0.03241353 0.1992355 0.02481809 0.001667409 0.02596555 0.0011126169
## 184 184 0.03257661 0.1907354 0.02494694 0.001889113 0.04214910 0.0012670350
## 185 185 0.03267071 0.1844930 0.02504554 0.001924944 0.05173424 0.0013053749
## 186 186 0.03287278 0.1764686 0.02521308 0.001724943 0.05186801 0.0013896001
## 187 187 0.03262875 0.1884915 0.02498907 0.001906146 0.03978826 0.0014003773
## 188 188 0.03322402 0.1571399 0.02550510 0.001836998 0.05043989 0.0014003086
## 189 189 0.03241555 0.1991533 0.02482205 0.001668537 0.02592897 0.0011155080
## 190 190 0.03267269 0.1845255 0.02503786 0.001930727 0.05131710 0.0012492323
## 191 191 0.03241599 0.1991400 0.02482068 0.001668057 0.02596483 0.0011141172
## 192 192 0.03267492 0.1873278 0.02500848 0.002016569 0.04858424 0.0014293491
## 193 193 0.03241231 0.1992892 0.02481827 0.001667457 0.02602182 0.0011158739
## 194 194 0.03269444 0.1847306 0.02502104 0.001254875 0.03317374 0.0007727593
## 195 195 0.03241282 0.1992572 0.02482012 0.001667109 0.02598829 0.0011152746
## 196 196 0.03241304 0.1992417 0.02482241 0.001666622 0.02595122 0.0011157063
## 197 197 0.03241304 0.1992360 0.02482040 0.001663900 0.02579357 0.0011128488
## 198 198 0.03267826 0.1871664 0.02501633 0.002019834 0.04876076 0.0014420739
## 199 199 0.03291366 0.1759317 0.02524279 0.002317305 0.05593881 0.0017293642
## 200 200 0.03258573 0.1904632 0.02494236 0.001896526 0.04139322 0.0012050762
## 201 201 0.03270438 0.1852210 0.02507770 0.001789592 0.04722276 0.0011755736
## 202 202 0.03262876 0.1885284 0.02499337 0.001896738 0.03903597 0.0013959521
## 203 203 0.03242174 0.1988564 0.02482805 0.001665860 0.02569423 0.0011156000
## 204 204 0.03242247 0.1988211 0.02482887 0.001666421 0.02570974 0.0011175675
## 205 205 0.03242220 0.1988275 0.02482759 0.001664984 0.02569562 0.0011165821
## 206 206 0.03265479 0.1876850 0.02505579 0.002045807 0.04121854 0.0015022222
## 207 207 0.03242159 0.1988437 0.02482838 0.001663210 0.02562531 0.0011173476
## 208 208 0.03242107 0.1988813 0.02482874 0.001662465 0.02566752 0.0011181276
## 209 209 0.03265413 0.1877302 0.02505404 0.002045260 0.04119437 0.0014993132
## 210 210 0.03242222 0.1988449 0.02482784 0.001664957 0.02574449 0.0011182482
## 211 211 0.03265668 0.1876433 0.02505607 0.002051778 0.04149237 0.0015042564
## 212 212 0.03241903 0.1989840 0.02482523 0.001663797 0.02582182 0.0011166440
## 213 213 0.03251013 0.1929782 0.02491608 0.001708898 0.04040613 0.0011654902
## 214 214 0.03270688 0.1842858 0.02503617 0.001241902 0.03332938 0.0007641282
## 215 215 0.03241820 0.1990202 0.02482473 0.001662506 0.02575708 0.0011178729
## 216 216 0.03265498 0.1877258 0.02504783 0.002055481 0.04177207 0.0014952481
## 217 217 0.03241672 0.1990814 0.02482366 0.001661302 0.02571403 0.0011189592
## 218 218 0.03259150 0.1903139 0.02494966 0.001910639 0.04217300 0.0012201240
## 219 219 0.03241515 0.1991480 0.02482193 0.001662119 0.02569389 0.0011199403
## 220 220 0.03267727 0.1867323 0.02507107 0.001492977 0.04605700 0.0011700818
## 221 221 0.03273181 0.1820802 0.02509055 0.001939639 0.04990527 0.0014310582
## 222 222 0.03259741 0.1899927 0.02496633 0.001908312 0.04301046 0.0012872989
## 223 223 0.03260732 0.1896895 0.02496608 0.001937122 0.04363399 0.0012374189
## 224 224 0.03252101 0.1925506 0.02493419 0.001717379 0.04174000 0.0011835719
## 225 225 0.03271167 0.1831596 0.02507319 0.001974520 0.05334456 0.0012816496
## 226 226 0.03241783 0.1990293 0.02482596 0.001661740 0.02567120 0.0011194123
## 227 227 0.03268637 0.1869863 0.02501947 0.002031423 0.04915889 0.0014510991
## 228 228 0.03273407 0.1820114 0.02509692 0.001942308 0.04993416 0.0014398433
## 229 229 0.03264507 0.1876066 0.02502042 0.001673915 0.04129320 0.0012549416
## 230 230 0.03241756 0.1990477 0.02482596 0.001663162 0.02578357 0.0011204303
## 231 231 0.03241816 0.1990219 0.02482649 0.001663076 0.02576580 0.0011205362
## 232 232 0.03294414 0.1720876 0.02529141 0.002277427 0.05900339 0.0015830135
## 233 233 0.03269721 0.1866651 0.02502766 0.002052690 0.05008129 0.0014681652
## 234 234 0.03306620 0.1675635 0.02535667 0.002410782 0.05659359 0.0017432456
## 235 235 0.03241782 0.1990370 0.02482623 0.001662943 0.02578869 0.0011204801
## 236 236 0.03282883 0.1787823 0.02513675 0.002126672 0.05168182 0.0015219176
## 237 237 0.03339563 0.1522882 0.02570700 0.002077293 0.06504305 0.0015201503
## 238 238 0.03297163 0.1709288 0.02531410 0.001783632 0.06197715 0.0012637892
## 239 239 0.03363603 0.1404458 0.02591614 0.001965316 0.06426498 0.0015099006
## 240 240 0.03241747 0.1990510 0.02482615 0.001663024 0.02579431 0.0011205616
## [1] "Best Model"
## nvmax
## 15 15
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## [1] "Coefficients of final model:"
## Estimate 2.5 % 97.5 %
## (Intercept) 1.967507e+00 1.951372e+00 1.983643e+00
## x4 -5.029613e-05 -6.769517e-05 -3.289709e-05
## x7 1.044485e-02 9.210735e-03 1.167897e-02
## x8 4.600676e-04 1.745882e-04 7.455470e-04
## x9 3.012246e-03 2.373171e-03 3.651320e-03
## x10 1.124834e-03 5.308712e-04 1.718798e-03
## x11 2.144872e+05 7.225403e+04 3.567204e+05
## x16 1.235851e-03 8.222581e-04 1.649445e-03
## x17 1.500100e-03 8.677607e-04 2.132439e-03
## x21 1.289568e-04 4.739125e-05 2.105223e-04
## stat14 -8.098545e-04 -1.285739e-03 -3.339704e-04
## stat22 -6.216928e-04 -1.103225e-03 -1.401604e-04
## stat98 3.592799e-03 3.120309e-03 4.065290e-03
## stat110 -3.234551e-03 -3.714185e-03 -2.754917e-03
## stat149 -6.442636e-04 -1.125085e-03 -1.634420e-04
## x18.sqrt 2.633233e-02 2.451034e-02 2.815431e-02
if (algo.stepwise.caret == TRUE){
test.model(model.stepwise, data.test
,method = 'leapSeq',subopt = NULL
,formula = formula, feature.names = feature.names, label.names = label.names
,id = id
,draw.limits = TRUE, transformation = t)
}
## [1] "Summary of predicted values: "
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.033 2.085 2.098 2.097 2.109 2.142
## [1] "leapSeq Test MSE: 0.000975960779489267"
if (algo.LASSO.caret == TRUE){
set.seed(1)
tune.grid= expand.grid(alpha = 1,lambda = 10^seq(from=-4,to=-2,length=100))
returned = train.caret.glmselect(formula = formula
,data = data.train
,method = "glmnet"
,subopt = 'LASSO'
,tune.grid = tune.grid
,feature.names = feature.names)
model.LASSO.caret = returned$model
}
## Aggregating results
## Selecting tuning parameters
## Fitting alpha = 1, lambda = 0.000673 on full training set
## glmnet
##
## 5584 samples
## 240 predictor
##
## No pre-processing
## Resampling: Cross-Validated (10 fold)
## Summary of sample sizes: 5026, 5026, 5026, 5025, 5025, 5026, ...
## Resampling results across tuning parameters:
##
## lambda RMSE Rsquared MAE
## 0.0001000000 0.03217604 0.2076378 0.02463999
## 0.0001047616 0.03216605 0.2080193 0.02463271
## 0.0001097499 0.03215581 0.2084119 0.02462527
## 0.0001149757 0.03214521 0.2088214 0.02461764
## 0.0001204504 0.03213414 0.2092526 0.02460977
## 0.0001261857 0.03212278 0.2096982 0.02460179
## 0.0001321941 0.03211130 0.2101502 0.02459395
## 0.0001384886 0.03209959 0.2106136 0.02458597
## 0.0001450829 0.03208787 0.2110788 0.02457807
## 0.0001519911 0.03207589 0.2115576 0.02456992
## 0.0001592283 0.03206361 0.2120525 0.02456151
## 0.0001668101 0.03205105 0.2125639 0.02455276
## 0.0001747528 0.03203827 0.2130889 0.02454363
## 0.0001830738 0.03202534 0.2136247 0.02453425
## 0.0001917910 0.03201247 0.2141622 0.02452476
## 0.0002009233 0.03199959 0.2147053 0.02451524
## 0.0002104904 0.03198683 0.2152469 0.02450592
## 0.0002205131 0.03197401 0.2157970 0.02449657
## 0.0002310130 0.03196133 0.2163472 0.02448724
## 0.0002420128 0.03194867 0.2169031 0.02447794
## 0.0002535364 0.03193651 0.2174434 0.02446884
## 0.0002656088 0.03192452 0.2179840 0.02445985
## 0.0002782559 0.03191317 0.2185039 0.02445125
## 0.0002915053 0.03190214 0.2190179 0.02444301
## 0.0003053856 0.03189188 0.2195050 0.02443546
## 0.0003199267 0.03188201 0.2199832 0.02442829
## 0.0003351603 0.03187261 0.2204494 0.02442119
## 0.0003511192 0.03186350 0.2209123 0.02441444
## 0.0003678380 0.03185435 0.2213911 0.02440798
## 0.0003853529 0.03184565 0.2218604 0.02440198
## 0.0004037017 0.03183636 0.2223717 0.02439557
## 0.0004229243 0.03182732 0.2228846 0.02438903
## 0.0004430621 0.03181798 0.2234272 0.02438241
## 0.0004641589 0.03180929 0.2239527 0.02437649
## 0.0004862602 0.03180091 0.2244760 0.02437074
## 0.0005094138 0.03179316 0.2249833 0.02436550
## 0.0005336699 0.03178636 0.2254592 0.02436182
## 0.0005590810 0.03178049 0.2259030 0.02435918
## 0.0005857021 0.03177611 0.2262845 0.02435764
## 0.0006135907 0.03177302 0.2266185 0.02435735
## 0.0006428073 0.03177085 0.2269220 0.02435821
## 0.0006734151 0.03177021 0.2271655 0.02436021
## 0.0007054802 0.03177180 0.2273115 0.02436341
## 0.0007390722 0.03177532 0.2273734 0.02436820
## 0.0007742637 0.03178103 0.2273339 0.02437527
## 0.0008111308 0.03178872 0.2272095 0.02438425
## 0.0008497534 0.03179868 0.2269860 0.02439474
## 0.0008902151 0.03181025 0.2267003 0.02440658
## 0.0009326033 0.03182403 0.2263242 0.02442053
## 0.0009770100 0.03183951 0.2258800 0.02443648
## 0.0010235310 0.03185645 0.2253792 0.02445410
## 0.0010722672 0.03187506 0.2248129 0.02447280
## 0.0011233240 0.03189422 0.2242448 0.02449241
## 0.0011768120 0.03191513 0.2236103 0.02451370
## 0.0012328467 0.03193594 0.2230211 0.02453515
## 0.0012915497 0.03195831 0.2223839 0.02455808
## 0.0013530478 0.03198178 0.2217298 0.02458233
## 0.0014174742 0.03200724 0.2210058 0.02460828
## 0.0014849683 0.03203333 0.2202933 0.02463477
## 0.0015556761 0.03206149 0.2195142 0.02466274
## 0.0016297508 0.03209149 0.2186891 0.02469267
## 0.0017073526 0.03212433 0.2177535 0.02472561
## 0.0017886495 0.03215961 0.2167291 0.02476039
## 0.0018738174 0.03219799 0.2155828 0.02479802
## 0.0019630407 0.03223759 0.2144270 0.02483693
## 0.0020565123 0.03228010 0.2131653 0.02487815
## 0.0021544347 0.03232400 0.2118950 0.02492038
## 0.0022570197 0.03237068 0.2105361 0.02496548
## 0.0023644894 0.03241497 0.2094431 0.02500870
## 0.0024770764 0.03246207 0.2082903 0.02505426
## 0.0025950242 0.03250962 0.2072633 0.02510040
## 0.0027185882 0.03256124 0.2061094 0.02514971
## 0.0028480359 0.03261698 0.2048281 0.02520189
## 0.0029836472 0.03267795 0.2033376 0.02525806
## 0.0031257158 0.03274474 0.2015904 0.02531822
## 0.0032745492 0.03281790 0.1995359 0.02538314
## 0.0034304693 0.03289721 0.1971733 0.02545231
## 0.0035938137 0.03298302 0.1944627 0.02552557
## 0.0037649358 0.03306655 0.1920954 0.02559726
## 0.0039442061 0.03315538 0.1894806 0.02567371
## 0.0041320124 0.03324640 0.1869069 0.02575144
## 0.0043287613 0.03334528 0.1838544 0.02583407
## 0.0045348785 0.03345324 0.1801635 0.02592289
## 0.0047508102 0.03357134 0.1756441 0.02601833
## 0.0049770236 0.03370048 0.1700841 0.02612222
## 0.0052140083 0.03384093 0.1632862 0.02623434
## 0.0054622772 0.03397992 0.1562894 0.02634471
## 0.0057223677 0.03412598 0.1482833 0.02645901
## 0.0059948425 0.03426556 0.1407789 0.02656611
## 0.0062802914 0.03441005 0.1323024 0.02667309
## 0.0065793322 0.03453531 0.1255949 0.02676171
## 0.0068926121 0.03465993 0.1186286 0.02684979
## 0.0072208090 0.03475383 0.1154784 0.02691587
## 0.0075646333 0.03484512 0.1129800 0.02697994
## 0.0079248290 0.03492552 0.1129284 0.02703595
## 0.0083021757 0.03501311 0.1129284 0.02709655
## 0.0086974900 0.03510900 0.1129284 0.02716295
## 0.0091116276 0.03521393 0.1129284 0.02723604
## 0.0095454846 0.03532874 0.1129284 0.02731679
## 0.0100000000 0.03545431 0.1129284 0.02740624
##
## Tuning parameter 'alpha' was held constant at a value of 1
## RMSE was used to select the optimal model using the smallest value.
## The final values used for the model were alpha = 1 and lambda = 0.0006734151.
## alpha lambda
## 42 1 0.0006734151
## alpha lambda RMSE Rsquared MAE RMSESD RsquaredSD MAESD
## 1 1 0.0001000000 0.03217604 0.2076378 0.02463999 0.001663038 0.02577808 0.001111820
## 2 1 0.0001047616 0.03216605 0.2080193 0.02463271 0.001662879 0.02578456 0.001111749
## 3 1 0.0001097499 0.03215581 0.2084119 0.02462527 0.001662772 0.02578835 0.001111783
## 4 1 0.0001149757 0.03214521 0.2088214 0.02461764 0.001662687 0.02579206 0.001111854
## 5 1 0.0001204504 0.03213414 0.2092526 0.02460977 0.001662606 0.02579645 0.001111902
## 6 1 0.0001261857 0.03212278 0.2096982 0.02460179 0.001662527 0.02580118 0.001111827
## 7 1 0.0001321941 0.03211130 0.2101502 0.02459395 0.001662466 0.02580045 0.001111815
## 8 1 0.0001384886 0.03209959 0.2106136 0.02458597 0.001662395 0.02579806 0.001111853
## 9 1 0.0001450829 0.03208787 0.2110788 0.02457807 0.001662263 0.02578479 0.001112120
## 10 1 0.0001519911 0.03207589 0.2115576 0.02456992 0.001662154 0.02577141 0.001112511
## 11 1 0.0001592283 0.03206361 0.2120525 0.02456151 0.001662044 0.02575579 0.001112819
## 12 1 0.0001668101 0.03205105 0.2125639 0.02455276 0.001661937 0.02573911 0.001113148
## 13 1 0.0001747528 0.03203827 0.2130889 0.02454363 0.001661840 0.02572502 0.001113705
## 14 1 0.0001830738 0.03202534 0.2136247 0.02453425 0.001661699 0.02571150 0.001114358
## 15 1 0.0001917910 0.03201247 0.2141622 0.02452476 0.001661456 0.02569458 0.001115028
## 16 1 0.0002009233 0.03199959 0.2147053 0.02451524 0.001661281 0.02568556 0.001115937
## 17 1 0.0002104904 0.03198683 0.2152469 0.02450592 0.001661096 0.02567535 0.001117204
## 18 1 0.0002205131 0.03197401 0.2157970 0.02449657 0.001660871 0.02566350 0.001118682
## 19 1 0.0002310130 0.03196133 0.2163472 0.02448724 0.001660803 0.02565038 0.001120437
## 20 1 0.0002420128 0.03194867 0.2169031 0.02447794 0.001660737 0.02563485 0.001122227
## 21 1 0.0002535364 0.03193651 0.2174434 0.02446884 0.001660557 0.02563398 0.001123456
## 22 1 0.0002656088 0.03192452 0.2179840 0.02445985 0.001660387 0.02564092 0.001124851
## 23 1 0.0002782559 0.03191317 0.2185039 0.02445125 0.001660424 0.02567129 0.001126188
## 24 1 0.0002915053 0.03190214 0.2190179 0.02444301 0.001660498 0.02571363 0.001127363
## 25 1 0.0003053856 0.03189188 0.2195050 0.02443546 0.001660652 0.02578101 0.001128158
## 26 1 0.0003199267 0.03188201 0.2199832 0.02442829 0.001660852 0.02585786 0.001128604
## 27 1 0.0003351603 0.03187261 0.2204494 0.02442119 0.001661567 0.02595495 0.001129407
## 28 1 0.0003511192 0.03186350 0.2209123 0.02441444 0.001662474 0.02605829 0.001130282
## 29 1 0.0003678380 0.03185435 0.2213911 0.02440798 0.001664138 0.02619287 0.001130783
## 30 1 0.0003853529 0.03184565 0.2218604 0.02440198 0.001666024 0.02633959 0.001131078
## 31 1 0.0004037017 0.03183636 0.2223717 0.02439557 0.001667362 0.02647868 0.001130441
## 32 1 0.0004229243 0.03182732 0.2228846 0.02438903 0.001668839 0.02662861 0.001130348
## 33 1 0.0004430621 0.03181798 0.2234272 0.02438241 0.001670742 0.02682500 0.001131870
## 34 1 0.0004641589 0.03180929 0.2239527 0.02437649 0.001672445 0.02702298 0.001133676
## 35 1 0.0004862602 0.03180091 0.2244760 0.02437074 0.001673378 0.02718432 0.001134411
## 36 1 0.0005094138 0.03179316 0.2249833 0.02436550 0.001674031 0.02733940 0.001134967
## 37 1 0.0005336699 0.03178636 0.2254592 0.02436182 0.001673627 0.02746066 0.001135271
## 38 1 0.0005590810 0.03178049 0.2259030 0.02435918 0.001672982 0.02758062 0.001135465
## 39 1 0.0005857021 0.03177611 0.2262845 0.02435764 0.001672615 0.02768462 0.001134994
## 40 1 0.0006135907 0.03177302 0.2266185 0.02435735 0.001672683 0.02781333 0.001134524
## 41 1 0.0006428073 0.03177085 0.2269220 0.02435821 0.001672805 0.02797402 0.001134587
## 42 1 0.0006734151 0.03177021 0.2271655 0.02436021 0.001672964 0.02815007 0.001134579
## 43 1 0.0007054802 0.03177180 0.2273115 0.02436341 0.001672986 0.02835360 0.001134274
## 44 1 0.0007390722 0.03177532 0.2273734 0.02436820 0.001672952 0.02857349 0.001134308
## 45 1 0.0007742637 0.03178103 0.2273339 0.02437527 0.001673427 0.02877260 0.001135376
## 46 1 0.0008111308 0.03178872 0.2272095 0.02438425 0.001673742 0.02896086 0.001135992
## 47 1 0.0008497534 0.03179868 0.2269860 0.02439474 0.001673206 0.02906738 0.001135792
## 48 1 0.0008902151 0.03181025 0.2267003 0.02440658 0.001672841 0.02917903 0.001135822
## 49 1 0.0009326033 0.03182403 0.2263242 0.02442053 0.001673600 0.02927276 0.001137737
## 50 1 0.0009770100 0.03183951 0.2258800 0.02443648 0.001674174 0.02936246 0.001139316
## 51 1 0.0010235310 0.03185645 0.2253792 0.02445410 0.001673597 0.02941451 0.001140007
## 52 1 0.0010722672 0.03187506 0.2248129 0.02447280 0.001672902 0.02945129 0.001140939
## 53 1 0.0011233240 0.03189422 0.2242448 0.02449241 0.001671790 0.02949074 0.001141457
## 54 1 0.0011768120 0.03191513 0.2236103 0.02451370 0.001670638 0.02951066 0.001142288
## 55 1 0.0012328467 0.03193594 0.2230211 0.02453515 0.001668868 0.02950093 0.001143207
## 56 1 0.0012915497 0.03195831 0.2223839 0.02455808 0.001667068 0.02948779 0.001144006
## 57 1 0.0013530478 0.03198178 0.2217298 0.02458233 0.001665795 0.02953265 0.001145218
## 58 1 0.0014174742 0.03200724 0.2210058 0.02460828 0.001664359 0.02957826 0.001146521
## 59 1 0.0014849683 0.03203333 0.2202933 0.02463477 0.001662316 0.02958390 0.001146447
## 60 1 0.0015556761 0.03206149 0.2195142 0.02466274 0.001660081 0.02956486 0.001146108
## 61 1 0.0016297508 0.03209149 0.2186891 0.02469267 0.001658146 0.02955629 0.001145356
## 62 1 0.0017073526 0.03212433 0.2177535 0.02472561 0.001656210 0.02952057 0.001144163
## 63 1 0.0017886495 0.03215961 0.2167291 0.02476039 0.001653468 0.02942202 0.001141699
## 64 1 0.0018738174 0.03219799 0.2155828 0.02479802 0.001650402 0.02931217 0.001138832
## 65 1 0.0019630407 0.03223759 0.2144270 0.02483693 0.001646859 0.02912381 0.001134568
## 66 1 0.0020565123 0.03228010 0.2131653 0.02487815 0.001643378 0.02889115 0.001130477
## 67 1 0.0021544347 0.03232400 0.2118950 0.02492038 0.001640214 0.02869074 0.001127206
## 68 1 0.0022570197 0.03237068 0.2105361 0.02496548 0.001637440 0.02854457 0.001124753
## 69 1 0.0023644894 0.03241497 0.2094431 0.02500870 0.001636231 0.02856915 0.001123038
## 70 1 0.0024770764 0.03246207 0.2082903 0.02505426 0.001635439 0.02863630 0.001120875
## 71 1 0.0025950242 0.03250962 0.2072633 0.02510040 0.001636288 0.02884636 0.001118586
## 72 1 0.0027185882 0.03256124 0.2061094 0.02514971 0.001637524 0.02906005 0.001116319
## 73 1 0.0028480359 0.03261698 0.2048281 0.02520189 0.001638511 0.02928254 0.001113626
## 74 1 0.0029836472 0.03267795 0.2033376 0.02525806 0.001639596 0.02951609 0.001110858
## 75 1 0.0031257158 0.03274474 0.2015904 0.02531822 0.001640771 0.02977156 0.001108251
## 76 1 0.0032745492 0.03281790 0.1995359 0.02538314 0.001642039 0.03004952 0.001106603
## 77 1 0.0034304693 0.03289721 0.1971733 0.02545231 0.001642713 0.03031451 0.001103963
## 78 1 0.0035938137 0.03298302 0.1944627 0.02552557 0.001643557 0.03063878 0.001101259
## 79 1 0.0037649358 0.03306655 0.1920954 0.02559726 0.001643874 0.03075322 0.001097512
## 80 1 0.0039442061 0.03315538 0.1894806 0.02567371 0.001645178 0.03087505 0.001095534
## 81 1 0.0041320124 0.03324640 0.1869069 0.02575144 0.001647559 0.03118708 0.001093902
## 82 1 0.0043287613 0.03334528 0.1838544 0.02583407 0.001650222 0.03145479 0.001092087
## 83 1 0.0045348785 0.03345324 0.1801635 0.02592289 0.001653033 0.03174750 0.001090365
## 84 1 0.0047508102 0.03357134 0.1756441 0.02601833 0.001656107 0.03202652 0.001089493
## 85 1 0.0049770236 0.03370048 0.1700841 0.02612222 0.001659471 0.03227022 0.001089784
## 86 1 0.0052140083 0.03384093 0.1632862 0.02623434 0.001662596 0.03244371 0.001089679
## 87 1 0.0054622772 0.03397992 0.1562894 0.02634471 0.001655793 0.03154336 0.001079619
## 88 1 0.0057223677 0.03412598 0.1482833 0.02645901 0.001648630 0.03068727 0.001070484
## 89 1 0.0059948425 0.03426556 0.1407789 0.02656611 0.001645134 0.03025832 0.001066819
## 90 1 0.0062802914 0.03441005 0.1323024 0.02667309 0.001641159 0.02972553 0.001063749
## 91 1 0.0065793322 0.03453531 0.1255949 0.02676171 0.001625879 0.02851711 0.001052289
## 92 1 0.0068926121 0.03465993 0.1186286 0.02684979 0.001612144 0.02752187 0.001042919
## 93 1 0.0072208090 0.03475383 0.1154784 0.02691587 0.001610443 0.02704016 0.001041853
## 94 1 0.0075646333 0.03484512 0.1129800 0.02697994 0.001611931 0.02618735 0.001043435
## 95 1 0.0079248290 0.03492552 0.1129284 0.02703595 0.001609927 0.02622841 0.001042604
## 96 1 0.0083021757 0.03501311 0.1129284 0.02709655 0.001607808 0.02622841 0.001041110
## 97 1 0.0086974900 0.03510900 0.1129284 0.02716295 0.001605588 0.02622841 0.001039509
## 98 1 0.0091116276 0.03521393 0.1129284 0.02723604 0.001603265 0.02622841 0.001038429
## 99 1 0.0095454846 0.03532874 0.1129284 0.02731679 0.001600836 0.02622841 0.001036789
## 100 1 0.0100000000 0.03545431 0.1129284 0.02740624 0.001598298 0.02622841 0.001033884
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## [1] "Coefficients"
## model.coef
## (Intercept) 1.994798e+00
## x4 -3.557360e-05
## x7 9.411222e-03
## x8 2.031626e-04
## x9 2.474607e-03
## x10 6.542710e-04
## x11 1.049210e+05
## x14 -1.178861e-04
## x16 8.977938e-04
## x17 9.784495e-04
## x19 5.171012e-05
## x21 6.074227e-05
## x22 -2.921618e-05
## stat4 -2.143004e-04
## stat14 -4.325345e-04
## stat15 -8.018226e-05
## stat20 -2.124474e-05
## stat22 -2.044018e-04
## stat23 1.592926e-04
## stat24 -1.985017e-04
## stat38 1.435944e-04
## stat41 -4.025251e-05
## stat71 5.426592e-05
## stat73 2.055012e-05
## stat81 5.561360e-05
## stat82 3.558390e-05
## stat87 -7.101204e-05
## stat91 -7.728314e-05
## stat98 3.234896e-03
## stat104 -1.933148e-05
## stat106 -3.896876e-05
## stat110 -2.829300e-03
## stat146 -2.269964e-04
## stat149 -2.573945e-04
## stat156 4.210880e-05
## stat195 8.094174e-05
## x18.sqrt 2.486624e-02
if (algo.LASSO.caret == TRUE){
test.model(model.LASSO.caret, data.test
,method = 'glmnet',subopt = "LASSO"
,formula = formula, feature.names = feature.names, label.names = label.names
,draw.limits = TRUE, transformation = t)
}
## [1] "Summary of predicted values: "
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.043 2.086 2.098 2.097 2.108 2.136
## [1] "glmnet LASSO Test MSE: 0.000981460529818087"
if (algo.LARS.caret == TRUE){
set.seed(1)
returned = train.caret.glmselect(formula = formula
,data = data.train
,method = "lars"
,subopt = 'NULL'
,feature.names = feature.names)
model.LARS.caret = returned$model
}
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, : There were missing values in resampled
## performance measures.
## Aggregating results
## Selecting tuning parameters
## Fitting fraction = 0.343 on full training set
## Least Angle Regression
##
## 5584 samples
## 240 predictor
##
## Pre-processing: centered (240), scaled (240)
## Resampling: Cross-Validated (10 fold)
## Summary of sample sizes: 5026, 5026, 5026, 5025, 5025, 5026, ...
## Resampling results across tuning parameters:
##
## fraction RMSE Rsquared MAE
## 0.00000000 0.03606793 NaN 0.02784038
## 0.01010101 0.03565193 0.1129284 0.02754623
## 0.02020202 0.03528001 0.1129284 0.02728142
## 0.03030303 0.03495359 0.1129284 0.02705546
## 0.04040404 0.03467806 0.1173078 0.02686420
## 0.05050505 0.03443166 0.1309574 0.02668954
## 0.06060606 0.03419927 0.1444738 0.02651611
## 0.07070707 0.03398641 0.1556405 0.02635110
## 0.08080808 0.03378353 0.1662310 0.02618999
## 0.09090909 0.03359029 0.1749559 0.02603455
## 0.10101010 0.03340901 0.1818110 0.02588836
## 0.11111111 0.03324012 0.1871669 0.02574752
## 0.12121212 0.03308754 0.1914872 0.02561695
## 0.13131313 0.03294573 0.1956591 0.02549536
## 0.14141414 0.03281006 0.1998416 0.02537749
## 0.15151515 0.03268433 0.2032506 0.02526603
## 0.16161616 0.03256902 0.2060004 0.02515948
## 0.17171717 0.03246806 0.2081598 0.02506229
## 0.18181818 0.03237723 0.2104060 0.02497363
## 0.19191919 0.03229119 0.2128724 0.02489111
## 0.20202020 0.03221222 0.2151627 0.02481488
## 0.21212121 0.03213933 0.2173169 0.02474361
## 0.22222222 0.03207469 0.2191537 0.02467908
## 0.23232323 0.03201841 0.2206881 0.02462222
## 0.24242424 0.03196891 0.2220890 0.02457169
## 0.25252525 0.03192768 0.2232403 0.02452823
## 0.26262626 0.03189064 0.2243355 0.02448953
## 0.27272727 0.03185866 0.2253094 0.02445730
## 0.28282828 0.03183146 0.2261347 0.02442890
## 0.29292929 0.03181120 0.2266824 0.02440722
## 0.30303030 0.03179587 0.2270574 0.02439188
## 0.31313131 0.03178418 0.2273075 0.02437952
## 0.32323232 0.03177540 0.2274525 0.02436982
## 0.33333333 0.03177002 0.2274551 0.02436292
## 0.34343434 0.03176758 0.2273418 0.02435869
## 0.35353535 0.03176767 0.2271228 0.02435674
## 0.36363636 0.03176905 0.2268605 0.02435582
## 0.37373737 0.03177161 0.2265653 0.02435565
## 0.38383838 0.03177631 0.2261791 0.02435738
## 0.39393939 0.03178146 0.2257894 0.02435986
## 0.40404040 0.03178676 0.2254066 0.02436260
## 0.41414141 0.03179244 0.2250144 0.02436622
## 0.42424242 0.03179819 0.2246332 0.02436974
## 0.43434343 0.03180473 0.2242222 0.02437371
## 0.44444444 0.03181153 0.2238063 0.02437819
## 0.45454545 0.03181857 0.2233865 0.02438300
## 0.46464646 0.03182556 0.2229781 0.02438806
## 0.47474747 0.03183265 0.2225732 0.02439308
## 0.48484848 0.03183942 0.2221950 0.02439746
## 0.49494949 0.03184567 0.2218502 0.02440148
## 0.50505051 0.03185208 0.2215057 0.02440584
## 0.51515152 0.03185877 0.2211538 0.02441060
## 0.52525253 0.03186550 0.2208074 0.02441541
## 0.53535354 0.03187230 0.2204639 0.02442046
## 0.54545455 0.03187937 0.2201134 0.02442595
## 0.55555556 0.03188661 0.2197598 0.02443131
## 0.56565657 0.03189395 0.2194067 0.02443673
## 0.57575758 0.03190156 0.2190465 0.02444227
## 0.58585859 0.03190959 0.2186717 0.02444824
## 0.59595960 0.03191808 0.2182802 0.02445467
## 0.60606061 0.03192702 0.2178737 0.02446136
## 0.61616162 0.03193631 0.2174553 0.02446837
## 0.62626263 0.03194572 0.2170374 0.02447543
## 0.63636364 0.03195548 0.2166081 0.02448268
## 0.64646465 0.03196563 0.2161652 0.02449013
## 0.65656566 0.03197587 0.2157234 0.02449752
## 0.66666667 0.03198644 0.2152711 0.02450532
## 0.67676768 0.03199741 0.2148052 0.02451342
## 0.68686869 0.03200853 0.2143363 0.02452165
## 0.69696970 0.03201981 0.2138647 0.02452994
## 0.70707071 0.03203137 0.2133845 0.02453838
## 0.71717172 0.03204330 0.2128917 0.02454707
## 0.72727273 0.03205542 0.2123954 0.02455575
## 0.73737374 0.03206755 0.2119033 0.02456411
## 0.74747475 0.03207972 0.2114144 0.02457238
## 0.75757576 0.03209205 0.2109235 0.02458077
## 0.76767677 0.03210460 0.2104256 0.02458928
## 0.77777778 0.03211753 0.2099146 0.02459805
## 0.78787879 0.03213075 0.2093952 0.02460720
## 0.79797980 0.03214410 0.2088739 0.02461673
## 0.80808081 0.03215743 0.2083586 0.02462631
## 0.81818182 0.03217073 0.2078494 0.02463600
## 0.82828283 0.03218406 0.2073418 0.02464585
## 0.83838384 0.03219752 0.2068317 0.02465577
## 0.84848485 0.03221086 0.2063316 0.02466553
## 0.85858586 0.03222437 0.2058275 0.02467544
## 0.86868687 0.03223775 0.2053332 0.02468543
## 0.87878788 0.03225115 0.2048423 0.02469545
## 0.88888889 0.03226461 0.2043533 0.02470584
## 0.89898990 0.03227807 0.2038695 0.02471616
## 0.90909091 0.03229156 0.2033887 0.02472649
## 0.91919192 0.03230519 0.2029057 0.02473701
## 0.92929293 0.03231894 0.2024209 0.02474764
## 0.93939394 0.03233286 0.2019334 0.02475849
## 0.94949495 0.03234685 0.2014466 0.02476951
## 0.95959596 0.03236089 0.2009624 0.02478061
## 0.96969697 0.03237487 0.2004852 0.02479166
## 0.97979798 0.03238897 0.2000071 0.02480287
## 0.98989899 0.03240320 0.1995280 0.02481445
## 1.00000000 0.03241747 0.1990510 0.02482615
##
## RMSE was used to select the optimal model using the smallest value.
## The final value used for the model was fraction = 0.3434343.
## fraction
## 35 0.3434343
## Warning: Removed 1 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## [1] "Coefficients"
## x4 x7 x8 x9 x10 x11 x14 x16
## -1.678795e-03 6.311330e-03 5.724416e-04 3.195826e-03 8.964505e-04 5.928021e-04 -1.382821e-04 1.784452e-03
## x17 x19 x21 x22 stat4 stat14 stat15 stat20
## 1.265831e-03 1.147980e-04 6.001201e-04 -1.838002e-05 -3.517363e-04 -7.337752e-04 -1.233320e-04 -2.101662e-05
## stat22 stat23 stat24 stat38 stat41 stat71 stat73 stat81
## -3.333158e-04 2.592532e-04 -3.251328e-04 2.311198e-04 -5.336199e-05 7.571107e-05 1.497565e-05 7.988942e-05
## stat82 stat87 stat91 stat98 stat104 stat106 stat110 stat146
## 4.326520e-05 -1.046714e-04 -1.188792e-04 5.669353e-03 -1.472087e-05 -4.921665e-05 -4.877776e-03 -3.732418e-04
## stat149 stat156 stat195 x18.sqrt
## -4.263690e-04 5.519235e-05 1.221591e-04 1.131682e-02
if (algo.LARS.caret == TRUE){
test.model(model.LARS.caret, data.test
,method = 'lars',subopt = NULL
,formula = formula, feature.names = feature.names, label.names = label.names
,draw.limits = TRUE, transformation = t)
}
## [1] "Summary of predicted values: "
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.044 2.086 2.098 2.097 2.108 2.136
## [1] "lars Test MSE: 0.000981554988047746"
sessionInfo()
## R version 3.5.2 (2018-12-20)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 17763)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C LC_TIME=English_United States.1252
##
## attached base packages:
## [1] parallel stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] knitr_1.21 htmltools_0.3.6 reshape2_1.4.3 lars_1.2
## [5] doParallel_1.0.14 iterators_1.0.10 caret_6.0-81 leaps_3.0
## [9] ggforce_0.1.3 rlist_0.4.6.1 car_3.0-2 carData_3.0-2
## [13] bestNormalize_1.3.0 scales_1.0.0 onewaytests_2.0 caTools_1.17.1.1
## [17] mosaic_1.5.0 mosaicData_0.17.0 ggformula_0.9.1 ggstance_0.3.1
## [21] lattice_0.20-38 DT_0.5 ggiraphExtra_0.2.9 ggiraph_0.6.0
## [25] investr_1.4.0 glmnet_2.0-16 foreach_1.4.4 Matrix_1.2-15
## [29] MASS_7.3-51.1 PerformanceAnalytics_1.5.2 xts_0.11-2 zoo_1.8-4
## [33] forcats_0.3.0 stringr_1.4.0 dplyr_0.8.0.1 purrr_0.3.0
## [37] readr_1.3.1 tidyr_0.8.2 tibble_2.0.1 ggplot2_3.1.0
## [41] tidyverse_1.2.1 usdm_1.1-18 raster_2.8-19 sp_1.3-1
## [45] pacman_0.5.0
##
## loaded via a namespace (and not attached):
## [1] readxl_1.3.0 backports_1.1.3 plyr_1.8.4 lazyeval_0.2.1 splines_3.5.2 mycor_0.1.1
## [7] crosstalk_1.0.0 leaflet_2.0.2 digest_0.6.18 magrittr_1.5 mosaicCore_0.6.0 openxlsx_4.1.0
## [13] recipes_0.1.4 modelr_0.1.3 gower_0.1.2 colorspace_1.4-0 rvest_0.3.2 ggrepel_0.8.0
## [19] haven_2.0.0 xfun_0.4 crayon_1.3.4 jsonlite_1.6 survival_2.43-3 glue_1.3.0
## [25] registry_0.5 gtable_0.2.0 ppcor_1.1 ipred_0.9-8 sjmisc_2.7.7 abind_1.4-5
## [31] rngtools_1.3.1 bibtex_0.4.2 Rcpp_1.0.0 xtable_1.8-3 units_0.6-2 foreign_0.8-71
## [37] stats4_3.5.2 lava_1.6.5 prodlim_2018.04.18 prediction_0.3.6.2 htmlwidgets_1.3 httr_1.4.0
## [43] RColorBrewer_1.1-2 pkgconfig_2.0.2 farver_1.1.0 nnet_7.3-12 labeling_0.3 tidyselect_0.2.5
## [49] rlang_0.3.1 later_0.8.0 munsell_0.5.0 cellranger_1.1.0 tools_3.5.2 cli_1.0.1
## [55] generics_0.0.2 moments_0.14 sjlabelled_1.0.16 broom_0.5.1 evaluate_0.13 ggdendro_0.1-20
## [61] yaml_2.2.0 ModelMetrics_1.2.2 zip_1.0.0 nlme_3.1-137 doRNG_1.7.1 mime_0.6
## [67] xml2_1.2.0 compiler_3.5.2 rstudioapi_0.9.0 curl_3.3 tweenr_1.0.1 stringi_1.3.1
## [73] highr_0.7 gdtools_0.1.7 stringdist_0.9.5.1 pillar_1.3.1 data.table_1.12.0 bitops_1.0-6
## [79] httpuv_1.4.5.1 R6_2.4.0 promises_1.0.1 gridExtra_2.3 rio_0.5.16 codetools_0.2-15
## [85] assertthat_0.2.0 pkgmaker_0.27 withr_2.1.2 nortest_1.0-4 mgcv_1.8-26 hms_0.4.2
## [91] quadprog_1.5-5 grid_3.5.2 rpart_4.1-13 timeDate_3043.102 class_7.3-14 rmarkdown_1.11
## [97] snakecase_0.9.2 shiny_1.2.0 lubridate_1.7.4